public double SimulatePF(double length, double crossSection, string materialName, string coolerName, double powerFactor) { try { CoolerCollection coolers = findCoolers(); Cooler cooler = (Cooler)coolers[coolerName]; MaterialsCollection materials = findMaterials(); Material material = (Material)materials[materialName]; SteadyStateSimulator ssSim = new SteadyStateSimulator(); return(ssSim.simulate(length, crossSection, material, cooler, powerFactor)); } catch (Exception ex) { throw new SoapException(ex.ToString(), new System.Xml.XmlQualifiedName("")); } }
/// <summary> /// Simulate the steady-state problem with the given strut /// and cooler. Output the results. /// </summary> /// <param name="strut"></param> /// <param name="cooler"></param> private void simulate(Strut strut, Cooler cooler) { Cursor savedCursor = this.Cursor; try { this.Cursor = Cursors.WaitCursor; this.Refresh(); double temp = steadyStateSim.simulate(strut.Length, strut.CrossSectionalArea, strut.Material, cooler); answerBox.Text = temp.ToString(); } finally { this.Cursor = savedCursor; } }
private State run(State state) { if (!requireLogin()) { // Should not happen as we have anonymous session login's in place throw new Exception("This should never happen"); //return null; } Cooler cooler = (Cooler)coolers[state.coolerName]; cooler.InputPowerCalculator = inputPowerCalc; Material material = (Material)materials[state.materialName]; double combinedCrossSection = state.numStruts * state.crossSection; state.cost = cooler.price + state.length * combinedCrossSection * material.price; state.stressLimit = material.yieldStrength * combinedCrossSection; // If temperature goes below known range for the given material the MATLAB code will generate an // ApplicationException. In that case we set temperature and inputPower to impossible values. UI // code can detect this and generate an appropriate message for the user. try { state.temperature = sim.simulate(state.length, combinedCrossSection, material, cooler, state.powerFactor); //TODO: This is a dummy value until we get the Beta(T) Calculations state.cooledLength = state.length * 0.998; state.inputPower = cooler.InputPower(state.temperature, state.powerFactor); } catch (ArgumentException) { state.temperature = -1; state.inputPower = -1; } if (state.problemName != null) { state.isValidSolution = solutionChecker.CheckSolution(state); persistState(state); } else { state.isValidSolution = false; } return(state); }