/// <summary> /// Read the data files and set up the MATLAB component. /// Would like to do this in a static constructor, but we don't have access to a /// HttpRequest object at that time, so it's not clear how to map the paths. /// </summary> private void init() { HttpRequest request = this.Context.Request; string dataDir = request.MapPath("Data"); string schemaDir = request.MapPath("Schema"); _logger.Debug("Loading SpecificPower.xml"); string specificPowerDataFile = Path.Combine(dataDir, "SpecificPower.xml"); string specificPowerSchemaFile = Path.Combine(schemaDir, "SpecificPower.xsd"); specificPowerData = new SpecificPowerDataManager(specificPowerDataFile, specificPowerSchemaFile); inputPowerCalc = new InputPowerCalculator(specificPowerData.Data); _logger.Debug("Loading Coolers.xml"); string coolerDataFile = Path.Combine(dataDir, "Coolers.xml"); string coolerSchemaFile = Path.Combine(schemaDir, "Coolers.xsd"); coolers = new CoolerCollection(coolerDataFile, coolerSchemaFile); foreach (Cooler c in coolers) { c.InputPowerCalculator = inputPowerCalc; } _logger.DebugFormat("{0} coolers loaded", coolers.Count); _logger.Debug("Loading Materials.xml"); string materialsDataFile = Path.Combine(dataDir, "Materials.xml"); string materialsSchemaFile = Path.Combine(schemaDir, "Materials.xsd"); materials = new MaterialsCollection(materialsDataFile, materialsSchemaFile); _logger.DebugFormat("{0} materials loaded", materials.Count); _logger.Debug("Loading Problems.xml"); string problemsDataFile = Path.Combine(dataDir, "Problems.xml"); string problemsSchemaFile = Path.Combine(schemaDir, "Problems.xsd"); problems = new ProblemCollection(problemsDataFile, problemsSchemaFile); _logger.DebugFormat("{0} problems loaded", problems.Count); _logger.Debug("Loading MathGates.xml"); string mathGateDataFile = Path.Combine(dataDir, "MathGates.xml"); string mathGateSchemaFile = Path.Combine(schemaDir, "MathGates.xsd"); mathGates = new MathGateCollection(mathGateDataFile, mathGateSchemaFile); _logger.DebugFormat("{0} math gates loaded", mathGates.Count); _logger.Debug("Initializing Optimizer"); optimizer = new Optimizer(coolers, materials); _logger.Debug("Initializaing SolutionChecker"); solutionChecker = new SolutionChecker(problems); _logger.Debug("Initializaing SteadyStateSimulator"); sim = new SteadyStateSimulator(); _logger.Debug("Initializing API"); api = new API(); }
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("")); } }