public void InitializeGraph()
        {
            gs = new GraphSolver();
            plainWater.Add(FluidType.WATER, 1.0);
            seaWater.Add(FluidType.SEA_WATER, 1.0);

            Tank t1 = new Tank("T1", 1000.0, plainWater, 500.0, new string[] { "V1" }, false);
            gs.addComponent(t1);
            t1.currentTemperature = 20.0;
            Tank t2 = new Tank("T2", 1000.0, seaWater, 500.0, new string[] { "V2" }, false);
            gs.addComponent(t2);
            t2.currentTemperature = 10.0;
            FlowLine v1 = new FlowLine("V1", "S1");
            gs.addComponent(v1);
            FlowLine v2 = new FlowLine("V2", "S1");
            gs.addComponent(v2);
            Junction s1 = new Junction("S1", new string[] { "P1" }, new string[] { "V1", "V2" }, "", new double[] { 0.5, 0.5 }, new double[] { 1.0, 1.0 });
            gs.addComponent(s1);
            FlowDriver p1 = new FlowDriver("P1", 300.0, 3.2, "S2");
            gs.addComponent(p1);
            Junction s2 = new Junction("S2", new string[] { "V3", "V4" }, new string[] { "P1" }, "C2", new double[] { 0.5, 0.5 }, new double[] { 1.0, 1.0 });
            gs.addComponent(s2);
            FlowLine v3 = new FlowLine("V3", "C2");
            gs.addComponent(v3);
            FlowLine v4 = new FlowLine("V4", "C2");
            gs.addComponent(v4);
            Junction c2 = new Junction("C2", new string[] { "T3" }, new string[] { "V3", "V4" });
            gs.addComponent(c2);
            Tank t3 = new Tank("T3", 1000.0, plainWater, 500.0, new string[] { }, false);          //We have no sinks, since we are the bottom of this food-chain.
            t3.currentTemperature = 30.0;
            gs.addComponent(t3);

            gs.connectComponents();
        }
        public void InitializeGraph()
        {
            gs = new GraphSolver();
            plainAir.Add(FluidType.AIR, 1.0);

            Tank t1 = new Tank("T1", double.MaxValue, plainAir, double.MaxValue, new string[] { "V1" }, false);             //Infinite tank!
            gs.addComponent(t1);
            FlowLine v1 = new FlowLine("V1", "P1");
            gs.addComponent(v1);
            FlowDriver p1 = new FlowDriver("P1", 100.0, 4.0, "V2");
            gs.addComponent(p1);
            FlowLine v2 = new FlowLine("V2", "T2");
            gs.addComponent(v2);
            Tank t2 = new Tank("T2", 1000.0, plainAir, 1000.0, new string[] { "P2" }, true);             //Sealed tanks should start full of air, so currentVolume = capacity.
            gs.addComponent(t2);

            PressureDifferentialFlowDriver p2 = new PressureDifferentialFlowDriver("P2", 100.0, 0.0, "V3", 1.0, 2.0);
            gs.addComponent(p2);
            FlowLine v3 = new FlowLine("V3", "T3");
            v3.setFlowAllowedPercent(0.0);
            gs.addComponent(v3);
            Tank t3 = new Tank("T3", 1000.0, plainAir, 1000.0, new string[] { }, true);             //Sealed tanks should start full of air, so currentVolume = capacity.
            gs.addComponent(t3);

            gs.connectComponents();
        }
Exemplo n.º 3
0
 public static void verifyMixtureAndTemperature(GraphSolver gs, string name, Dictionary<FluidType, double> truthMap, double temp)
 {
     Dictionary<FluidType, double> componentMap = gs.getComponent(name).getCurrentFluidTypeMap();
     double componentTemp = gs.getComponent(name).getInletTemperature();
     Assert.AreEqual(temp, componentTemp, 0.00001);
     foreach(KeyValuePair<FluidType, double> iter in truthMap)
     {
         Assert.AreEqual(true, componentMap.ContainsKey(iter.Key));
         Assert.AreEqual(iter.Value, componentMap[iter.Key], 0.00001);
     }
 }
Exemplo n.º 4
0
        public static void UglyTest()
        {
            gs = new GraphSolver();
            plainWater.Add(FluidType.WATER, 1.0);
            seaWater.Add(FluidType.SEA_WATER, 1.0);

            //Tanks t1 and t2 are the base sources, and go to v1 and v2 directly (return comes back through v11 and v12)
            gs.addComponent(new Tank("T1", 1000.0, plainWater, 500.0, new string[] { "V1" }, false));
            gs.addComponent(new Tank("T2", 1000.0, plainWater, 500.0, new string[] { "V2" }, false));
            gs.addComponent(new FlowLine("V1", "C1"));         //v1 and v2 both go into S1
            gs.addComponent(new FlowLine("V2", "C1"));

            //Valves v1 and v2 combine into c1, and then split immediatelu to s1
            gs.addComponent(new Junction("C1", new string[] { "S1" }, new string[] { "V1", "V2" }, "", new double[] { 0.5, 0.5 }, new double[] { 1.0, 1.0 }));

            //Splitter s1 splits the flow into v3 and v4, so that they can got to p1 and p2, which go further on to v5 and v6
            gs.addComponent(new Junction("S1", new String[] { "V3", "V4" }, new string[] { "C1" }, "", new double[] { 0.5, 0.5 }, new double[] { 1.0, 1.0 }));
            gs.addComponent(new FlowLine("V3", "P1"));
            gs.addComponent(new FlowLine("V4", "P2"));
            gs.addComponent(new FlowDriver("P1", 100, 3.2, "V5"));
            gs.addComponent(new FlowDriver("P2", 100, 3.2, "V6"));
            gs.addComponent(new FlowLine("V5", "C2"));
            gs.addComponent(new FlowLine("V6", "C2"));

            //Valves v5 and v6 then get combined into c2, which immediately splits out with s2
            gs.addComponent(new Junction("C2", new string[] { "S2" }, new string[] { "V5", "V6" }));

            //Valves v7, v8, and v9 all go in between s2 and c3
            gs.addComponent(new Junction("S2", new String[] { "V7", "V8", "V9" }, new string[] { "C2" }, "C3", new double[] { .1, .4, .5 }, new double[] { .1, .6, 1.0 }));
            gs.addComponent(new FlowLine("V7", "C3"));
            gs.addComponent(new FlowLine("V8", "C3"));
            gs.addComponent(new FlowLine("V9", "C3"));
            gs.addComponent(new Junction("C3", new string[] { "V10" }, new string[] { "V7", "V8", "V9" }));

            //Valve v10 goes between c3 and s3
            gs.addComponent(new FlowLine("V10", "S3"));
            gs.addComponent(new Junction("S3", new String[] { "V11", "V12" }, new string[] { "V10" }, "", new double[] { 0.5, 0.5 }, new double[] { 1.0, 1.0 }));

            //Valves v11 and v12 go from s3 back to the tanks t1 and t2
            gs.addComponent(new FlowLine("V11", "T1"));
            gs.addComponent(new FlowLine("V12", "T2"));

            //v2.setFlowAllowedPercent(0.25);
            //v4.setFlowAllowedPercent(0.2);
            //t1.setCurrentVolume(0.0);
            //v5.setMaxFlow(100.0);
            //v0.setMaxFlow(85.0);
            //v5.setFlowAllowedPercent(0.5);

            gs.connectComponents();
            gs.solveMimic();
            gs.printSolution();
        }
Exemplo n.º 5
0
        public void InitializeGraph()
        {
            gs = new GraphSolver();
            plainWater.Add(FluidType.WATER, 1.0);

            Tank t1 = new Tank("T1", 1000.0, plainWater, 500.0, new string[] { "V1" }, false);
            gs.addComponent(t1);
            FlowLine v1 = new FlowLine("V1", "P1");
            gs.addComponent(v1);
            FlowDriver p1 = new FlowDriver("P1", 100.0, 3.2, "V2");
            gs.addComponent(p1);
            FlowLine v2 = new FlowLine("V2", "T2");
            gs.addComponent(v2);
            Tank t2 = new Tank("T2", 1000.0, plainWater, 500.0, new string[] { }, false);          //We have no sinks, since we are the bottom of this food-chain.
            gs.addComponent(t2);

            gs.connectComponents();
        }
Exemplo n.º 6
0
        public void InitializeGraph()
        {
            gs = new GraphSolver();
            plainWater.Add(FluidType.WATER, 1.0);

            Tank t1 = new Tank("T1", 1000.0, plainWater, 500.0, new string[] { "V1" }, false);
            gs.addComponent(t1);
            FlowLine v1 = new FlowLine("V1", "S1");
            gs.addComponent(v1);
            Tank t2 = new Tank("T2", 1000.0, plainWater, 500.0, new string[] { "V2" }, false);          //We have no sinks, since we are the bottom of this food-chain.
            gs.addComponent(t2);
            FlowLine v2 = new FlowLine("V2", "S1");
            gs.addComponent(v2);
            Junction s1 = new Junction("S1", new string[] { "P1" }, new string[] { "V1", "V2" }, "", new double[] { 0.5, 0.5 }, new double[] { 0.6, 1.0 });
            gs.addComponent(s1);
            FlowDriver p1 = new FlowDriver("P1", 200.0, 3.2, "V3");
            gs.addComponent(p1);
            FlowLine v3 = new FlowLine("V3", "T3");
            gs.addComponent(v3);
            Tank t3 = new Tank("T3", 1000.0, plainWater, 500.0, new string[] { }, false);          //We have no sinks, since we are the bottom of this food-chain.
            gs.addComponent(t3);

            gs.connectComponents();
        }
Exemplo n.º 7
0
        public void InitializeGraph()
        {
            gs = new GraphSolver();
            plainWater.Add(FluidType.WATER, 1.0);

            Tank t1 = new Tank("T1", 1000.0, plainWater, 500.0, new string[] { "V0" }, false);
            gs.addComponent(t1);
            FlowLine v0 = new FlowLine("V0", "C1");
            gs.addComponent(v0);
            Junction c1 = new Junction("C1", new string[] { "V1", "V2" }, new string[] { "V0" });
            gs.addComponent(c1);
            FlowLine v1 = new FlowLine("V1", "P1");
            gs.addComponent(v1);
            FlowLine v2 = new FlowLine("V2", "P2");
            gs.addComponent(v2);
            FlowDriver p1 = new FlowDriver("P1", 100.0, 3.2, "V3");
            gs.addComponent(p1);
            FlowDriver p2 = new FlowDriver("P2", 100.0, 3.2, "V4");
            gs.addComponent(p2);
            FlowLine v3 = new FlowLine("V3", "C2");
            gs.addComponent(v3);
            FlowLine v4 = new FlowLine("V4", "C2");
            gs.addComponent(v4);
            Junction c2 = new Junction("C2", new string[] { "V5" }, new string[] { "V3", "V4" });
            gs.addComponent(c2);
            FlowLine v5 = new FlowLine("V5", "T2");
            gs.addComponent(v5);
            Tank t2 = new Tank("T2", 1000.0, plainWater, 500.0, new string[] { }, false);          //We have no sinks, since we are the bottom of this food-chain.
            gs.addComponent(t2);

            gs.connectComponents();
        }
Exemplo n.º 8
0
 public static void verifyFlow(GraphSolver gs, String name, double flow)
 {
     double componentFlow = gs.getComponent(name).getFlow();
     Assert.AreEqual(flow, componentFlow, 0.00001);
 }