IEnumerator Start() { ShapeCombiner c = new ShapeCombiner(65536, shouldOptimize: true, shouldUpload: true, infiniteBounds: false); MeshObjectCreator.CreateObjectsRealtime(c, _mat, transform); Tube tube = new Tube(8); for (int i = 0; i < _ribbonCount; i++) { tube.Clear(); float offset = Random.Range(0, 360); float radius = Random.Range(0.5f, 1.5f); for (int j = 0; j < _segments; j++) { tube.Add(new MeshPoint(new Vector3(j * 0.04f, radius * Mathf.Sin(j * 0.1f + offset), radius * Mathf.Cos(j * 0.1f + offset))), 0.03f); } yield return(null); c.AddShape(tube); } c.FinalizeCurrentMesh(); }
public ShellAndTubeHeatExchanger Configure() { if (!FindMaterialPort("TubeIn").IsConnected || !FindMaterialPort("TubeOut").IsConnected || !FindMaterialPort("ShellIn").IsConnected || !FindMaterialPort("ShellOut").IsConnected) { throw new InvalidOperationException("Shell&Tube heat Exchanger not connected correctly"); } var TubeIn = FindMaterialPort("TubeIn").Streams[0]; var TubeOut = FindMaterialPort("TubeOut").Streams[0]; var ShellIn = FindMaterialPort("ShellIn").Streams[0]; var ShellOut = FindMaterialPort("ShellOut").Streams[0]; var shellSystem = ShellIn.System; var tubeSystem = TubeIn.System; TubeStreams.Add(TubeIn); ShellStreams.Add(ShellIn); var numTotalCells = NumberOfPasses * Discretization; for (int i = 0; i < numTotalCells; i++) { if (i < numTotalCells - 1) { TubeStreams.Add(new MaterialStream(Name + ".TubeStream[" + (i + 1) + "]", tubeSystem)); ShellStreams.Add(new MaterialStream(Name + ".ShellStream[" + (i + 1) + "]", shellSystem)); } else { TubeStreams.Add(TubeOut); ShellStreams.Add(ShellOut); } QExchanged.Add(new HeatStream(Name + ".Q[" + (i + 1) + "]", System)); var currentTubeCell = new HeatExchangerCell(Name + ".TubeWall[" + (i + 1) + "]", tubeSystem); Tube.Add(currentTubeCell); var currentShellCell = new HeatExchangerCell(Name + ".ShellWall[" + (i + 1) + "]", shellSystem); Shell.Add(currentShellCell); currentTubeCell.Connect("In", TubeStreams[i]); currentShellCell.Connect("In", ShellStreams[i]); if (i < numTotalCells - 1) { currentTubeCell.Connect("Out", TubeStreams[i + 1]); currentShellCell.Connect("Out", ShellStreams[i + 1]); } else { currentTubeCell.Connect("Out", TubeStreams[i + 1]); currentShellCell.Connect("Out", ShellStreams[i + 1]); } } switch (FlowPattern) { case FlowPattern.CounterCurrent: for (int i = 0; i < numTotalCells; i++) { Tube[i].Connect("Duty", QExchanged[i]); Tube[i].FindHeatPort("Duty").Direction = PortDirection.Out; Shell[numTotalCells - i - 1].Connect("Duty", QExchanged[i]); } break; case FlowPattern.CoCurrent: for (int i = 0; i < numTotalCells; i++) { Tube[i].Connect("Duty", QExchanged[i]); Tube[i].FindHeatPort("Duty").Direction = PortDirection.Out; Shell[i].Connect("Duty", QExchanged[i]); } break; default: throw new NotSupportedException("Flow pattern " + FlowPattern + " is not supported."); } for (int i = 0; i < numTotalCells; i++) { //AddVariables(Tube[i].Variables.ToArray()); // AddVariables(Shell[i].Variables.ToArray()); //AddVariables(QExchanged[i].Q); } return(this); }