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(); 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", 200.0, 3.2, "S1"); gs.addComponent(p1); Junction s1 = new Junction("S1", new string[] { "V2", "V3" }, new string[] { "P1" }, "", new double[] { 0.5, 0.5 }, new double[] { 0.6, 1.0 }); gs.addComponent(s1); 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); 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(); }
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(); }
public override void connectSelf(Dictionary<string, FlowComponent> components) { for (int i = 0; i < deliveryNames.Length; i++) { FlowComponent deliveryComponent = components[deliveryNames[i]]; deliveryComponent.setSource(this); deliveryComponents[i] = deliveryComponent; if (deliveryComponents.Length > 1) { indexByName[deliveryComponent.name] = i; setCombiningVolumeMap = new double[deliveryComponents.Length]; } } for (int i = 0; i < sourceNames.Length; i++) { FlowComponent source = components[sourceNames[i]]; sourceComponents[i] = source; if (sourceComponents.Length > 1) { indexByName[source.name] = i; setCombiningVolumeMap = new double[sourceComponents.Length]; } } if(!String.IsNullOrEmpty(linkedCombinerName)) { linkedCombiner = (Junction)components[linkedCombinerName]; } //TODO: Add code to validate the configuration, so that we are either 'one to many' or 'many to one'. Never many to many (and never 0 anywhere) hasMultipleDeliveryComponents = deliveryComponents.Length > 1; }