示例#1
0
        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);
        }
示例#2
0
        private void plotInputPower()
        {
            Cooler cooler = (Cooler)coolersListBox.SelectedItem;

            if (cooler == null)
            {
                return;
            }

            double powerFactor = getPowerFactor();
            double yMax        = 0.0;

            double[] x = new double[301];
            double[] y = new double[301];

            for (int i = 0; i <= 300; i++)
            {
                x[i] = (double)i;
                y[i] = cooler.InputPower(x[i], powerFactor);
                if (y[i] < 0.0)
                {
                    y[i] = 0.0;
                }
                if (y[i] > yMax)
                {
                    yMax = y[i];
                }
            }

            coolerVisualizer.XAxisLabel = "Temp (Deg K)";
            coolerVisualizer.YAxisLabel = "Input Power (Watts)";
            coolerVisualizer.PlotLabel  = cooler.Name;
            coolerVisualizer.XData      = x;
            coolerVisualizer.YData      = y;
            coolerVisualizer.Y_Max      = cooler.MaxInputPower;

            coolerVisualizer.Redraw();
        }