public void DisplaySubstance(Substance substance) { for (int i = 0; i < Substance.NUM_BITS; i++) { bool bitSet = ((1 << i) & substance.State) > 0; if (invert) bitSet = !bitSet; onBits[i].SetActive(bitSet); } }
public void Combine(ActionEnum action, Substance secondSubstance) { switch (action) { case ActionEnum.ADD: state = state + secondSubstance.state; break; case ActionEnum.SUB: state = state - secondSubstance.state; break; case ActionEnum.XOR: state = state ^ secondSubstance.state; break; case ActionEnum.OR: state = state | secondSubstance.state; break; case ActionEnum.AND: state = state & secondSubstance.state; break; case ActionEnum.NOT: state = ~state; break; case ActionEnum.NOP: break; } state = state & STATE_MASK; }
public virtual IEnumerator PerformAction(Substance substance) { yield return new WaitForSeconds(timeToReact); ShowReactionFX(true); substance.Combine(action, new Substance(constant)); yield return new WaitForSeconds(timeToPlayFX); ShowReactionFX(false); yield return StartCoroutine(Measure(substance)); }
public IEnumerator Measure(Substance substance) { for (int i = 0; i < 4; i++) { if (measuresBits[i]) { bool bitSet = ((1 << i) & substance.State) > 0; Jot.Out("Measured bit", i, bitSet); if (bitSet && MeasurementFX.Length > i && MeasurementFX[i]) { MeasurementFX[i].SetActive(true); } } } yield return new WaitForSeconds(1f); TurnOffMeasurementFX(); Jot.Out("Done measuring"); }
public override IEnumerator PerformAction(Substance substance) { yield return new WaitForSeconds(timeToReact); var successfulReaction = (substance.State & 1) > 0; if(successfulReaction) { Jot.Out("Submission successful!"); var gold = (GameObject)Instantiate(goldPrefab, transform.position, UnityEngine.Random.rotationUniform); gold.GetComponent<Rigidbody>().AddForce(goldForce, ForceMode.VelocityChange); var spawned = (GameObject)Instantiate(successEnding.objectToSpawnWhenStatusHappens, transform.position + new Vector3(0, 3, 0), Quaternion.identity); Destroy(spawned, 1f); successEnding.soundToPlay.Play(); substance.Clear(); } else { failureEnding.timesEndingtimeEncounteredBeforeResetting--; var spawned = (GameObject)Instantiate(failureEnding.objectToSpawnWhenStatusHappens, transform.position + failureEnding.objectToSpawnWhenStatusHappens.transform.position, Quaternion.identity); Destroy(spawned, 1f); if(failureEnding.soundToPlay != null) failureEnding.soundToPlay.Play(); substance.Clear(); } yield return new WaitForSeconds(timeToPlayFX); if(failureEnding.timesEndingtimeEncounteredBeforeResetting <= 0) { //change the state of the reaction vessel back to zero? //reset game? FindObjectOfType<GameMeta>().RoundFinishedDueToFailure(); } if(successfulReaction) { var meta = FindObjectOfType<GameMeta>(); if(meta != null) meta.AddToScore(); substance.ResetState(); } ShowReactionFX(false); }
private double CalculateDeltaEnthalpy(Substance s, double temperature, double pressure) { double Tc = s.CriticalPropsAndAccentricFactor.CriticalTemperature; double Pc = s.CriticalPropsAndAccentricFactor.CriticalPressure; double rf = 0.75; double z = 1.0; double R = Constants.R; double molarWeight = s.MolarWeight; double a = 0.42748 * R * R * Math.Pow(Tc, 2.5) / Pc; double b = 0.08664 * R * Tc / Pc; double Tr = temperature / Tc; double Pr = pressure / Pc; double A = 0.42748 * Pr / Math.Pow(Tr, 2.5); double B = 0.09664 * Pr / Tr; int iter = 0; double f; double fp; double dz; do { iter++; f = -A * B - z * ((B * (B + 1.0) - A) + z * (1.0 - z)); fp = -(B * (B + 1.0) - A) - z * (2.0 - 3.0 * z); dz = -f / fp; if (Math.Abs(dz) > z * rf) { dz = (dz >= 0.0) ? Math.Abs(z * rf) : -Math.Abs(z * rf); } z = z + dz; } while (Math.Abs(f) > 5.0e-8 && iter < 100); double discr = (1.0 + 3.0 * z) * (1.0 - z) + 4.0 * (B * (B + 1.0) - A); if (discr >= 0.0) { double z1 = 0.5 * (1.0 - z + Math.Sqrt(discr)); double z2 = 1.0 - z - z1; z = Math.Max(z, Math.Max(z1, z2)); } double deltaH = R * temperature * (z - 1.0 - 1.5 * a * a / b * Math.Log(1.0 + b * pressure / z)); return(deltaH / molarWeight); }
public override void Act(params object[] args) { if (Life.Energy < this.EnergyCost) { this.Life.Stimulate(this.Life.EnergyLowStimulus); return; } Life.Energy -= this.EnergyCost; double param = 0; Substance substance = null; SubstanceCapsule res = null; foreach (object obj in args) { if (obj is double || obj is long || obj is int) { param += Convert.ToDouble(obj); } else if (substance == null) { if (obj is Substance) { substance = obj as Substance; } else if (obj is SubstanceCapsule) { substance = (obj as SubstanceCapsule).Substance; } } } if (substance == null || !Life.Resources.ContainsKey(substance)) { if (Life.Resources.Count <= 0) { return; } substance = Life.SubstanceCapsuleList.GetRandom().Substance; } res = Life.Resources[substance]; var amount = res.TransferLimit * Math.Tan(0.85 * Math.PI * (Life.World.Random.NextDouble() - 0.49)) / 10 + 0.5; amount = res.Take(amount); Life.World[Life.X, Life.Y].Add(substance, amount); }
public void SurfaceSelectFloodFill(Voxel voxel, int faceI, Substance substance) { if (voxel == null) { return; } if (voxel.substance != substance) { return; } VoxelFace face = voxel.faces[faceI]; if (face.IsEmpty()) { return; } if (face.addSelected || face.storedSelected) // stop at boundaries of stored selection { return; } SelectFace(voxel, faceI); Vector3 position = voxel.transform.position; for (int sideNum = 0; sideNum < 4; sideNum++) { int sideFaceI = Voxel.SideFaceI(faceI, sideNum); SurfaceSelectFloodFill(voxel, sideFaceI, substance); Vector3 newPos = position + Voxel.DirectionForFaceI(sideFaceI); SurfaceSelectFloodFill(VoxelAt(newPos, false), faceI, substance); newPos += Voxel.DirectionForFaceI(faceI); SurfaceSelectFloodFill(VoxelAt(newPos, false), Voxel.OppositeFaceI(sideFaceI), substance); } if (selectMode != SelectMode.SURFACE) { selectionBounds = voxel.GetFaceBounds(faceI); } else { selectionBounds.Encapsulate(voxel.GetFaceBounds(faceI)); } selectMode = SelectMode.SURFACE; SetMoveAxes(position + new Vector3(0.5f, 0.5f, 0.5f) - Voxel.OppositeDirectionForFaceI(faceI) / 2); }
public void Remove(string name) { Substance s = null; IEnumerator e = substances.GetEnumerator(); while (e.MoveNext()) { s = (e.Current) as Substance; if (s.Name.Equals(name)) { break; } } if (s != null) { substances.Remove(s); } }
public bool ShootAiming(Substance substance, int[] enemyTypes) { ShotingParticles(); bullet = Instantiate(bulletPrefab, transform.GetChild(0).position, transform.rotation, Global.inst.Drops.transform); bullet.GetComponent <Rigidbody>().AddForce(Camera.main.ScreenPointToRay(Input.mousePosition).direction *bulletSpeed); bullet.GetComponent <ParticleEffectSelector>().substance = substance; bullet.GetComponent <Bullet>().substance = substance; //warum return? return(CombatManager.Shoot( pointerSupplier.cameraMovementController.RotationCenterPoint.position, Camera.main.ScreenPointToRay(Input.mousePosition).direction, maxReach, damagePerHit, substance, enemyTypes)); }
private void fillTextFields(Substance substance) { TFName.Enabled = true; TFName.Selectable = false; TFName.StringValue = substance.name; TFType.Enabled = true; TFType.Selectable = false; TFType.StringValue = substance.type.ToString(); TFMinTemp.Enabled = true; TFMinTemp.Selectable = false; TFMinTemp.StringValue = substance.lowTemperature.ToString(); TFMaxTemp.Enabled = true; TFMaxTemp.Selectable = false; TFMaxTemp.StringValue = substance.highTemperature.ToString(); }
private void PopulateIt(IList list) { IEnumerator en = list.GetEnumerator(); while (en.MoveNext()) { Substance subst = (Substance)en.Current; ListViewItem lvi = new ListViewItem(); ListViewItem.ListViewSubItem lvsi = new ListViewItem.ListViewSubItem(lvi, subst.Name); lvi.SubItems.Insert(0, lvsi); lvsi = new ListViewItem.ListViewSubItem(lvi, subst.FormulaString); lvi.SubItems.Insert(1, lvsi); this.listViewSubstances.Items.Add(lvi); } }
public async Task <Node <Substance> > CreateSubstanceAsync(Substance substance) { try { var substances = await _client.Cypher .Create("(s:Substance {substance})") .WithParams(new { substance }) .Return <Node <Substance> >("s") .ResultsAsync; return(substances.Single()); } catch (Exception ex) { _logger.LogError("Error executing graph query: {0}", ex.Message); return(null); } }
public double GetLiquidDensity(ArrayList materialComponents, double temperature) { double density = 0.0; double den = 0; double massFrac; foreach (MaterialComponent mc in materialComponents) { Substance s = mc.Substance; //ThermalPropsAndCoeffs tpc = s.ThermalPropsAndCoeffs; massFrac = mc.GetMassFractionValue(); //den = ThermalPropCalculator.CalculateLiquidDensity(temperature, tpc.LiqDensityCoeffs); den = thermalPropCalculator.CalculateLiquidDensity(temperature, s); density += den * massFrac; } return(density); }
public override void SetObjectData() { base.SetObjectData(); int persistedClassVersion = (int)info.GetValue("ClassPersistenceVersionDryingMaterial", typeof(int)); if (persistedClassVersion == 1) { this.name = (string)info.GetValue("Name", typeof(string)); this.isUserDefined = (bool)info.GetValue("IsUserDefined", typeof(bool)); this.absoluteDryMaterial = CompositeSubstance.RecallSubstance(info); this.moisture = Substance.RecallSubstance(info, "MoistureName"); this.materialType = (MaterialType)info.GetValue("MaterialType", typeof(MaterialType)); this.solutionType = (SolutionType)info.GetValue("SolutionType", typeof(SolutionType)); this.duhringLines = (CurveF[])RecallArrayObject("DuhringLines", typeof(CurveF[])); } }
//calculated value unit is J/kg.K, t unit is K public double CalculateLiquidHeatCapacity(double t, Substance s) { double cp = 0; if (liquidCpTablePerrys.ContainsKey(s.Name)) { //return cp from GetCp(t) is J/kmol.K cp = liquidCpTablePerrys[s.Name].GetCp(t); } else if (liquidCpTableYaws.ContainsKey(s.Name)) { //return cp from GetCp(t) is J/mol.K. So needs to multiple 1000 to convert J/kmol.K cp = 1000 * liquidCpTableYaws[s.Name].GetCp(t); } cp = cp / s.MolarWeight; return(cp); }
public async Task <IActionResult> Put(string substanceId, [FromBody] Substance substance) { if (ModelState.IsValid) { try { var s = await _repository.UpdateSubstanceAsync(substanceId, substance); return(Ok(s)); } catch (Exception ex) { _logger.LogError("Error {0}", ex.Message); } } return(BadRequest("Something wrong...")); }
//the default constructor is for humid air //public HumidGasCalculator(Substance gas, Substance moisture, MoistureProperties moistureProperties) { public HumidGasCalculator(Substance gas, Substance moisture) { this.gas = gas; this.moisture = moisture; //this.moistureProperties = moistureProperties; moistureMolarMass = moisture.MolarWeight; gasMolarMass = gas.MolarWeight; moistureGasMolarMassRatio = moistureMolarMass / gasMolarMass; //psychrometricRatio = gasSolventPsychrometricRatioTable[gas.Name][moisture.Name]; moistureProperties = new MoistureProperties(moisture); gasProperties = new GasProperties(gas); //this.specificHeatOfMoisture = moistureProperties.GetSpecificHeatOfVapor(); //this.specificHeatOfDryGas = gasProperties.GetSpecificHeatOfDryGas(293.15); diffusivityCalculator = new GasDiffusivityCalculator(gas, moisture); }
//public DryingMaterialCatalog(IList list) { // materialList = list; //} private void InitializeCatalog() { SubstanceCatalog sc = SubstanceCatalog.GetInstance(); //Substance absoluteDryMaterial = sc.GetSubstance("Dry Material"); Substance absoluteDryMaterial = sc.GetGenericSubstance(); Substance moisture = sc.GetSubstance("water"); ArrayList dryMatComponents = new ArrayList(); dryMatComponents.Add(new MaterialComponent(absoluteDryMaterial)); CompositeSubstance dryMat = new CompositeSubstance("Generic Dry Material", dryMatComponents); DryingMaterial dm = new DryingMaterial("Generic Material", MaterialType.GenericMaterial, dryMat, moisture, false); //materialList.Add(dm); DryingMaterial milk = (DryingMaterial)dm.Clone(); milk.Name = "Milk"; milk.MaterialType = MaterialType.SpecialFood; //materialList.Add(milk); }
public override IInteraction[] GenerateInteractionsFromTarget(InteractionEvent interactionEvent) { if (registry == null) { return(null); } // Create a separate interaction for each possible substance to dispense IInteraction[] interactions = new IInteraction[substances.Length]; for (int i = 0; i < substances.Length; i++) { // Retrieve substance from the Registry Substance substance = registry.FromId(substances[i]); // Ensure the substance was successfully retrieved. if (substance == null) { // If it isn't, let them know what it is! Debug.LogWarning("No substance in Registry for " + substances[i] + ". Add it."); return(null); } // Determine how many moles to dispense float moles; if (useMillilitres) { moles = amount / substance.MillilitersPerMole; } else { moles = amount; } // Add the specific dispence interaction to the list. interactions[i] = new DispenseSubstanceInteraction { RangeCheck = true, Substance = new SubstanceEntry(substance, moles), Name = String.IsNullOrWhiteSpace(InteractionName) ? "Fill with " + substances[i] : InteractionName + " " + substances[i] }; } return(interactions); }
private void UpdateBoxSelectionRecursive(OctreeNode node, Bounds bounds, Substance substance) { if (node == null) { return; } if (!bounds.Intersects(node.bounds)) { return; } if (node.size == 1) { Voxel voxel = node.voxel; if (substance == selectObjectSubstance && voxel.objectEntity != null && ThingInBoxSelection(voxel.objectEntity.marker, bounds)) { SelectThing(voxel.objectEntity.marker); return; } if (voxel.substance != substance) { return; } for (int faceI = 0; faceI < voxel.faces.Length; faceI++) { if (voxel.faces[faceI].IsEmpty()) { continue; } if (ThingInBoxSelection(new VoxelFaceReference(voxel, faceI), bounds)) { SelectFace(voxel, faceI); } } } else { foreach (OctreeNode branch in node.branches) { UpdateBoxSelectionRecursive(branch, bounds, substance); } } }
//calculated value unit is Pa, t unit is K public double CalculateSaturationTemperature(double p, Substance s) { double t = 0; if (s.Name.Equals("water")) { t = CalculateWaterSaturationTemperature(p); } else if (vapPressureTablePerrys.ContainsKey(s.Name)) { t = vapPressureTablePerrys[s.Name].GetSaturationTemperature(p); } else if (vapPressureTableYaws.ContainsKey(s.Name)) { t = vapPressureTableYaws[s.Name].GetSaturationTemperature(p); } return(t); }
private static void AssertCreateFails(decimal quantity, Substance subst, Unit substUnit, Route route, int order, Shape shape, ProductDto dto, Package package, decimal prodQuantity, Unit unit) { try { Product.Create(dto) .Shape(shape) .Package(package) .Quantity(unit, prodQuantity) .Substance(order, subst, quantity, substUnit) .Route(route); Assert.Fail(); } catch (System.Exception e) { Assert.IsNotInstanceOfType(e, typeof(AssertFailedException)); } }
protected void ConvertToElement() { PrimaryElement component = base.smi.master.GetComponent <PrimaryElement>(); float mass = component.Mass; float temperature = component.Temperature; if (mass <= 0f) { Util.KDestroyGameObject(base.gameObject); } else { SimHashes hash = SimHashes.ToxicSand; Substance substance = ElementLoader.FindElementByHash(hash).substance; GameObject gameObject = substance.SpawnResource(base.smi.master.transform.GetPosition(), mass, temperature, byte.MaxValue, 0, false, false, false); PopFXManager.Instance.SpawnFX(PopFXManager.Instance.sprite_Resource, ElementLoader.FindElementByHash(hash).name, gameObject.transform, 1.5f, false); Util.KDestroyGameObject(base.smi.gameObject); } }
/// <summary> /// /// </summary> /// <param name="t">Temperature in K</param> /// <param name="s">The substance to be calculated</param> /// <returns>Calculated heat capacity value (unit is J/kg.K)</returns> public double CalculateGasHeatCapacity(double t, Substance s) { double cp = 0; if (gasCpTablePerrys.ContainsKey(s.Name)) { //Cp from Perry's correlation is in J/kmol.K. cp = gasCpTablePerrys[s.Name].GetCp(t); } else if (gasCpTableYaws.ContainsKey(s.Name)) { //Cp from Yaw's correlation is in J/mol.K. needs to convert to J/kmol.K by multipling 1000 cp = 1000 * gasCpTableYaws[s.Name].GetCp(t); } cp = cp / s.MolarWeight; return(cp); }
public Form1() { InitializeComponent(); Img = new Bitmap(pictureBox1.ClientSize.Width, pictureBox1.ClientSize.Height); World = new World(pictureBox1.ClientSize.Width, pictureBox1.ClientSize.Height); World.OnUpdate += World_OnUpdate; World.OnError += World_OnError; GDI = Graphics.FromImage(Img); pictureBox1.Image = Img; CheckForIllegalCrossThreadCalls = false; DoubleBuffered = true; var nutrition = new Substance(World, 0.96, 1); World.AddInitialResource(nutrition, 100); World.Start(16); var life = new Life(World.CreateSpeciesID(), World); World.Birth(life, World.Width / 2, World.Height / 2); }
public void TestBoilingPoints3() { MaterialType mtSodiumChloride = new MaterialType(null, "Potassium Carbonate", Guid.NewGuid(), 2.29, 4.17, MaterialState.Solid, 44.0, 1200); for (double d = 1.0; d >= 0.0; d -= .2) { Substance sodiumChloride = (Substance)mtSodiumChloride.CreateMass(100, 31); Substance acetone = (Substance)m_brs.MyMaterialCatalog["Acetone"].CreateMass(d * 100, 31); double pressure_1Atm = 101325.0; // pascals. Mixture m = new Mixture("BP Tester"); m.AddMaterial(sodiumChloride); m.AddMaterial(acetone); double ebp = m.GetEstimatedBoilingPoint(pressure_1Atm); Console.WriteLine("BP of " + m.ToString() + " is " + ebp + "."); } }
private void OnUserRequestPreviewShot(Cut cut) { Substance eye = cut.Properties.Find(x => x.Name.ToLower() == "eye"); if (eye != null) { Substance <ObservableCollection <BindingVector3> > eye_vec = eye as Substance <ObservableCollection <BindingVector3> >; m_SceneCameraOverride.Transform.Position = eye_vec.Data[0].BackingVector; } else { return; } Substance target = cut.Properties.Find(x => x.Name.ToLower() == "center"); if (target != null) { Substance <ObservableCollection <BindingVector3> > target_vec = target as Substance <ObservableCollection <BindingVector3> >; Matrix4 mat = Matrix4.LookAt(m_SceneCameraOverride.Transform.Position, target_vec.Data[0].BackingVector, -Vector3.UnitY); m_SceneCameraOverride.Transform.Rotation = mat.ExtractRotation().ToDoublePrecision(); } else { return; } Substance fovy = cut.Properties.Find(x => x.Name.ToLower() == "fovy"); if (fovy != null) { Substance <ObservableCollection <PrimitiveBinding <float> > > fovy_sub = fovy as Substance <ObservableCollection <PrimitiveBinding <float> > >; m_SceneCameraOverride.FieldOfView = fovy_sub.Data[0].Value; } else { m_SceneCameraOverride.FieldOfView = 60.0f; } OverrideSceneCamera(m_View); }
/// <summary> /// Tries to subtract given amount of given substance from it's vials. Returns true if the required amount was removed /// </summary> public bool TryUsingSubstance(Substance substanceToUse, int amount) { if (amount <= 0) { return(false); } for (int index = 0; index < amountOfActiveVials; index++) { if (substanceVials[index].CurrentSubstance.Equals(substanceToUse)) { if ((amount = substanceVials[index].TryToRemoveAmount(amount)) == 0) { return(true); } } } return(false); }
//calculated value unit is J/kg, t unit is K public double CalculateEvaporationHeat(double t, Substance s) { //formulation coming from Perry's Chemical Engineer's Handbook double r = 0; if (evapHeatTablePerrys.ContainsKey(s.Name)) { double tc = s.CriticalPropsAndAccentricFactor.CriticalTemperature; //returned r from GetEvaporationHeat(t, tc) is in J/kmol r = evapHeatTablePerrys[s.Name].GetEvaporationHeat(t, tc); } else if (evapHeatTableYaws.ContainsKey(s.Name)) { //returned r from GetEvaporationHeat(t) is in J/mol r = 1000 * evapHeatTableYaws[s.Name].GetEvaporationHeat(t); } r = r / s.MolarWeight; return(r); }
public double GetSpecificHeatRatio(ArrayList materialComponents, double temperature) { double heatCapacity = 0.0; double cp = 0; //double molarWeight = 0.0; double w; double molarFrac; double totalMole = 0.0; foreach (MaterialComponent mc in materialComponents) { Substance s = mc.Substance; if (s.Name == "Generic Dry Material" || s is CompositeSubstance) { continue; } w = s.MolarWeight; molarFrac = mc.GetMassFractionValue() / w; totalMole += molarFrac; } foreach (MaterialComponent mc in materialComponents) { Substance s = mc.Substance; if (s.Name == "Generic Dry Material" || s is CompositeSubstance) { continue; } w = s.MolarWeight; //ThermalPropsAndCoeffs tpc = s.ThermalPropsAndCoeffs; molarFrac = mc.GetMassFractionValue() / w / totalMole; //heatCapacity = ThermalPropCalculator.CalculateGasHeatCapacity1(temperature, tpc.GasCpCoeffs); //unit from CalculateGasHeatCapacity(temperature, s) is J/kg.K //need to convert to kJ/kmol.K to be aligned with universal gas constant R. heatCapacity = thermalPropCalculator.CalculateGasHeatCapacity(temperature, s); cp += heatCapacity * molarFrac * w / 1000; } return(cp / (cp - Constants.R)); }
public void SubstanceSelect(Substance substance) { foreach (Voxel v in substance.voxels) { for (int i = 0; i < 6; i++) { if (!v.faces[i].IsEmpty()) { SelectFace(v, i); if (selectMode != SelectMode.SURFACE) { selectionBounds = v.GetFaceBounds(i); } else { selectionBounds.Encapsulate(v.GetFaceBounds(i)); } selectMode = SelectMode.SURFACE; } } } }
public override void DrawWindow() { base.DrawWindow(); EditorGUILayout.LabelField("Value"); int oldI = sIndex; sIndex = EditorGUILayout.Popup(sIndex, names); if (oldI != sIndex) { substance = NodeEditor.Instance.GetSubstance(sIndex); } amount = EditorGUILayout.FloatField("Amount", amount); temperature = EditorGUILayout.FloatField("Temperature", temperature); EditorGUILayout.LabelField("Chemical Name: " + substance.chemical_name); EditorGUILayout.LabelField("Boiling Point: " + substance.boiling_point); EditorGUILayout.LabelField("Aggregate State: " + substance.aggregate_state); EditorGUILayout.LabelField("Chemical Name: " + substance.chemical_name); // windowTitle = names[index]; }
//calculated value unit is J/kmol.K, t unit is K public double CalculateGasMeanHeatCapacity(double p, double t1, double t2, Substance s) { double cp = 0; if (s.Name.Equals("water")) { if (Math.Abs(t1 - t2) > 1.0e-4) { cp = CalculateWaterMeanHeatCapacity(p, t1, t2); } else { cp = CalculateWaterMeanHeatCapacity(p, t1, t1 + 1); } } else { cp = CalculateWaterMeanHeatCapacity(p, t1, t2); } return(cp); }
public static double GetSpecificHeatRatio(ArrayList materialComponents, double temperature) { double heatCapacity = 0.0; double cp = 0; //double molarWeight = 0.0; double w; double molarFrac; double totalMole = 0.0; foreach (MaterialComponent mc in materialComponents) { Substance s = mc.Substance; if (s.Name == "Generic Dry Material" || s is CompositeSubstance) { continue; } w = s.MolarWeight; molarFrac = mc.GetMassFractionValue() / w; totalMole += molarFrac; } foreach (MaterialComponent mc in materialComponents) { Substance s = mc.Substance; if (s.Name == "Generic Dry Material" || s is CompositeSubstance) { continue; } w = s.MolarWeight; ThermalPropsAndCoeffs tpc = s.ThermalPropsAndCoeffs; molarFrac = mc.GetMassFractionValue() / w / totalMole; //since heat capacity from ThermalPropCalculator is in J/kmol.K, it is necessary to //convert into kJ/kmol.K to be aligned with the unit of universal gas constant R heatCapacity = ThermalPropCalculator.CalculateGasHeatCapacity1(temperature, tpc.GasCpCoeffs) / 1000; cp += heatCapacity * molarFrac; } return(cp / (cp - Constants.R)); }
private static bool SubstanceIsValid(Substance substance) { return !string.IsNullOrWhiteSpace(substance.Name); }
protected void TestPerformAction() { var subs = new Substance(testSubstanceState); StartCoroutine(PerformAction(subs)); this.Delay(timeToReact + 0.01f, () => { Jot.Out("Result is", subs); }); }
private static void AssertCreateFails(decimal quantity, Substance subst, Unit substUnit, Route route, int order, Shape shape, ProductDto dto, Package package, decimal prodQuantity, Unit unit) { try { Product.Create(dto) .Shape(shape) .Package(package) .Quantity(unit, prodQuantity) .Substance(order, subst, quantity, substUnit) .Route(route); Assert.Fail(); } catch (System.Exception e) { Assert.IsNotInstanceOfType(e, typeof (AssertFailedException)); } }
public SubstanceViewModel(Substance substance) { this.substance = substance; }
protected void TestDisplaySubstance() { var subs = new Substance(testSubstanceState); DisplaySubstance(subs); }