Пример #1
0
        public CoolerCollection(string dataFile, string schemaFile)
        {
            XPathNavigator navigator = openDocumentForReading(dataFile, schemaFile);

            if (!navigator.MoveToChild("coolers", ""))
            {
                throw new Exception("XML Parsing error");
            }
            if (!navigator.MoveToChild("cooler", ""))
            {
                throw new Exception("XML Parsing error");
            }

            do
            {
                Cooler cooler = new Cooler(navigator.Clone());
                objectList.Add(cooler);
            } while (navigator.MoveToNext());
        }
Пример #2
0
            public CandidateSolution(Material m, Cooler c, double targetTemp, double strengthRequirement, Problem problem)
            {
                material = m;
                cooler   = c;

                // If yieldStrength < 0, that means the value is unknown.  We cannot use materials without knowing
                // their yieldStrength, so solutions with this material are not feasible.
                if (m.yieldStrength < 0.0)
                {
                    feasible = false;
                    return;
                }

                // The lowest temp for which we have thermal conductivity data for a particular material sets an effective
                // lower bound on target temp.  We cannot use materials in a situation where they will be outside the
                // temperature range where we know this property.
                double minThermalData = m.MP[0].temp;

                if (targetTemp <= minThermalData)
                {
                    feasible = false;
                    return;
                }

                // The strut(s) must be strong enough to support the load.  Figure out what the minimum cross section
                // is.  This is the cross section for each strut.
                strutCrossSection  = strengthRequirement / m.yieldStrength / problem.SupportNumber;
                strutCrossSection *= 1.00001;                   // add tiny bit to avoid precision problems when comparing later
                double calcStrength = m.yieldStrength * strutCrossSection * problem.SupportNumber;

                if (calcStrength < strengthRequirement)
                {
                    throw new Exception("We have a math precision problem here");
                }

                // If the material is not strong enough to support the load given the maximum cross section
                // specified in the problem, it's not feasible
                if (strutCrossSection > problem.MaxStrutCrossSection)
                {
                    feasible = false;
                    return;
                }

                // If the material is so strong that a cross section less than the minimum specified can support the
                // load, we have to adjust the cross section to the minimum specified.
                if (strutCrossSection < problem.MinStrutCrossSection)
                {
                    strutCrossSection = problem.MinStrutCrossSection;
                }

                // Need to determine the maximum power factor which will result in an input power that meets
                // the problem constraints.  We will always use the maximum power factor which does not violate
                // our input power constraint as we are only optimizing our cost to build (not operating costs).
                coolerPowerFactor = c.maxPowerFactor(problem.InputPowerLimit, targetTemp);
                double actualInputPower = c.InputPower(targetTemp, coolerPowerFactor);

                if (actualInputPower > problem.InputPowerLimit)
                {
                    throw new Exception("Error in maxPowerFactor calculation");
                }


                // Given the cooler, material, cross section, target temperature, and power factor, we can calculate the
                // minimum strut length which will allow us to reach that temperature.
                strutLength = Optimizer.steadyStateSim.strutLength(targetTemp, strutCrossSection * problem.SupportNumber, m, c, coolerPowerFactor);

                // If the Matlab code cannot come up with a minimum strut length, the mateial is not feasible
                // given the other parameters.
                if (double.IsNaN(strutLength))
                {
                    feasible = false;
                    return;
                }

                // If reaching the target temperature requires a longer strut than the maximum length specified,
                // the material is not feasible.
                if (strutLength > problem.MaxStrutLength)
                {
                    feasible = false;
                    return;
                }

                // If we can reach the target temperature with a strut shorter than the minimum, we still have to
                // use a strut that meets the minimum length requirement.
                if (strutLength < problem.MinStrutLength)
                {
                    strutLength = problem.MinStrutLength;
                    // Now that we have adjusted the strutLength to be longer, we'll reach a colder temperature.
                    // It could be that we are now below the min temp for which we have data on our strut material.
                    double steadyStateTemp;
                    try {
                        steadyStateTemp = Optimizer.steadyStateSim.simulate(strutLength, strutCrossSection * problem.SupportNumber, material, cooler, coolerPowerFactor);
                    } catch (ArgumentException) {
                        steadyStateTemp = -1;
                    }

                    if (steadyStateTemp < minThermalData)
                    {
                        // Here we reduce the power factor enough to get the temperature back in range.
                        coolerPowerFactor = MaxPowerFactor(0.0, coolerPowerFactor, minThermalData, problem);
                    }
                }

                // OK, we have a feasible solution - figure out what it's going to cost.
                feasible = true;
                double strutVolume = strutCrossSection * strutLength * problem.SupportNumber;
                double strutCost   = m.price * strutVolume;

                solutionCost = c.price + strutCost;
            }
Пример #3
0
        public double simulate(double length, double crossSection, Material material, Cooler cooler, double powerFactor)
        {
            double[,] data = cooler.getDataNative("CPM");
            for (int i = 0; i < data.GetLength(0); i++)
            {
                data[i, 0]  = 300.0 - (300.0 - data[i, 0]) * powerFactor;
                data[i, 1] *= powerFactor;
            }
            MWNumericArray coolerData   = (MWNumericArray)data;
            MWNumericArray materialData = material.getData("PM");

            // We assume that if the MATLAB code generates an exception or returns NaN, it's becuase the parameters
            // imply a system which is infeasible.  That might mean that the steady state temperature would be below
            // the lowest conductivity data point for the material.
            try {
                MWNumericArray ssTemp = (MWNumericArray)matlabSim.steadystatetemperature(length, crossSection, materialData, coolerData);
                double         answer = ssTemp.ToScalarDouble();
                if (Double.IsNaN(answer))
                {
                    throw new ArgumentException("Bad arguments to simulate method");
                }
                else
                {
                    return(answer);
                }
            } catch (Exception ex) {
                throw new ArgumentException("Bad arguments to simulate method", ex);
            }
        }
Пример #4
0
 public double simulate(double length, double crossSection, Material material, Cooler cooler)
 {
     try {
         MWNumericArray lengthData       = new MWNumericArray(length);
         MWNumericArray crossSectionData = new MWNumericArray(crossSection);
         MWNumericArray materialData     = material.getData("PM");
         MWNumericArray coolerData       = cooler.getData("CPM");
         MWNumericArray ssTemp           = (MWNumericArray)matlabSim.steadystatetemperature(
             lengthData, crossSectionData, materialData, coolerData);
         return(ssTemp.ToScalarDouble());
     } catch (Exception ex) {
         throw new ArgumentException("Bad arguments to simulate method", ex);
     }
 }
Пример #5
0
        public double strutLength(double targetTemp, double crossSection, Material material, Cooler cooler, double powerFactor)
        {
            double[,] data = cooler.getDataNative("CPM");
            for (int i = 0; i < data.GetLength(0); i++)
            {
                data[i, 0]  = 300.0 - (300.0 - data[i, 0]) * powerFactor;
                data[i, 1] *= powerFactor;
            }
            MWNumericArray targetTempData   = new MWNumericArray(targetTemp);
            MWNumericArray crossSectionData = new MWNumericArray(crossSection);
            MWNumericArray materialData     = material.getData("PM");
            MWNumericArray coolerData       = (MWNumericArray)data;
            MWNumericArray strutLength      = (MWNumericArray)matlabSim.strutlength(
                targetTempData, crossSectionData, materialData, coolerData);
            double answer = strutLength.ToScalarDouble();

            return(answer);
        }
Пример #6
0
        public double strutLength(double targetTemp, double crossSection, Material material, Cooler cooler)
        {
            MWNumericArray targetTempData   = new MWNumericArray(targetTemp);
            MWNumericArray crossSectionData = new MWNumericArray(crossSection);
            MWNumericArray materialData     = material.getData("PM");
            MWNumericArray coolerData       = cooler.getData("CPM");
            MWNumericArray strutLength      = (MWNumericArray)matlabSim.strutlength(
                targetTempData, crossSectionData, materialData, coolerData);

            return(strutLength.ToScalarDouble());
        }