// >0 if it is more mass in source volume // TIME IS APPLIED public float GetMassBalance(ChemVolume receiverVol) { ChemVolume sourceVol = GetSourceForReceiver(receiverVol); if (sourceVol.name == "SteamStorage") { int x = 0; } float res = (sourceVol.Pressure - receiverVol.Pressure) * Kmass * gateGap * plant.PlantDeltaTime; if (res > 0) { float probableMass = GasUtils.CalculateMass(sourceVol.Pressure, receiverVol.Volume, sourceVol.Mix.Temp); float dm = probableMass - receiverVol.Mix.Mass; if (dm > 0 && res > dm) { res = dm; } } if (float.IsNaN(res) || float.IsInfinity(res)) { throw new UnityException("GetMassBalance result is Nan or Infinity"); } return(res); }
public void MoveHeat(ChemVolume receiverVol, float heat) { ChemVolume sourceVol = GetSourceForReceiver(receiverVol); float dh = Mathf.Min(sourceVol.Mix.Heat, heat); sourceVol.Mix.Heat -= dh; receiverVol.Mix.Heat += dh; }
// >0 if it is more heat in source volume public float GetHeatBalance(ChemVolume receiverVol) { ChemVolume sourceVol = GetSourceForReceiver(receiverVol); if (sourceVol.Mix.Mass == 0 || receiverVol.Mix.Mass == 0) { return(0); } return((sourceVol.Mix.Temp - receiverVol.Mix.Temp) * Kheat); }
public override void OnInspectorGUI() { ChemVolume cv = (ChemVolume)target; DrawDefaultInspector(); GUILayout.Label("Heat: " + cv.Mix.Heat); GUILayout.Label("Mass: " + cv.Mix.Mass); GUILayout.Label("Heat Capacity: " + cv.Mix.HeatCapacity); GUILayout.Label("Pressure: " + cv.Pressure); }
private ChemVolume GetSourceForReceiver(ChemVolume receiverVol) { if (VolumeIn == receiverVol) { return(VolumeOut); } else if (VolumeOut == receiverVol) { return(VolumeIn); } throw new UnityException("receiverVol is set incorrectly. Possibly a bug"); }
// Use this for initialization void Start() { ChemVolume vol = GetComponent <ChemVolume>(); bool old = vol.Mix.Infinite; vol.Mix.Infinite = false; ChemFraction fraction = new ChemFraction(Element); fraction.Mass = Pressure * vol.Volume / (Constants.R * Temperature); vol.Mix.AddFraction(fraction); vol.Mix.Heat = Temperature * Element.HeatCap * fraction.Mass; vol.Mix.RebuildCache(); vol.Mix.Infinite = old; }
public void MoveMass(ChemVolume receiverVol, float mass) { ChemVolume sourceVol = GetSourceForReceiver(receiverVol); ChemMix mix = sourceVol.Mix.TakeMix(mass); receiverVol.Mix.AddMix(mix); if (receiverVol == VolumeOut) { Flow += mass; } else { Flow -= mass; } }
void Awake() { vol = GetComponent <ChemVolume>(); plant = GetComponent <Plant>(); }
void Awake() { volume = GetComponent <ChemVolume>(); }