Ejemplo n.º 1
0
        /// <summary> Reads wake loss model settings from form and adds wake model to list and calls background_worker to conduct turbine calcs. </summary>
        public void GenWakeModel()
        {
            int    wakeModelType = ReadWakeModelType();
            double horizExp      = ReadHorizExp();

            TurbineCollection.PowerCurve thisPowerCurve = GetPowerCurve();
            double avgTI     = ReadTI();
            string wakeCombo = ReadWakeCombo();

            double DW_Spacing = 0;
            double CW_Spacing = 0;
            double ambRough   = 0;

            if (wakeModelType == 1)
            { // read in inputs for DAWM
                DW_Spacing = ReadDW_Spacing();
                CW_Spacing = ReadCW_Spacing();
                ambRough   = ReadAmbRough();
            }

            // Check to see if wake model has been added
            bool wakeModelExists = thisInst.wakeModelList.WakeModelExists(wakeModelType, horizExp, avgTI, thisPowerCurve.name, DW_Spacing, CW_Spacing, ambRough, wakeCombo);

            if (wakeModelExists == false)
            {
                thisInst.wakeModelList.AddWakeModel(wakeModelType, horizExp, avgTI, thisPowerCurve, DW_Spacing, CW_Spacing, ambRough, wakeCombo);
            }

            int wakeModelInd = 0;

            for (int i = 0; i < thisInst.wakeModelList.NumWakeModels; i++)
            {
                if (thisInst.wakeModelList.wakeModels[i].wakeModelType == wakeModelType && thisInst.wakeModelList.wakeModels[i].horizWakeExp == horizExp &&
                    thisInst.wakeModelList.wakeModels[i].powerCurve.name == thisPowerCurve.name && thisInst.wakeModelList.wakeModels[i].ambTI == avgTI &&
                    thisInst.wakeModelList.wakeModels[i].comboMethod == wakeCombo)
                {
                    if (wakeModelType == 1)
                    {
                        if (thisInst.wakeModelList.wakeModels[i].DW_Spacing == DW_Spacing && thisInst.wakeModelList.wakeModels[i].CW_Spacing == CW_Spacing &&
                            thisInst.wakeModelList.wakeModels[i].ambRough == ambRough)
                        {
                            wakeModelInd = i;
                            break;
                        }
                    }
                    else
                    {
                        wakeModelInd = i;
                        break;
                    }
                }
            }

            if (thisInst.turbineList.TurbineCount > 0)
            {
                if (thisInst.turbineList.turbineEsts[0].EstsExistForWakeModel(thisInst.wakeModelList.wakeModels[wakeModelInd], thisInst.wakeModelList))
                {
                    MessageBox.Show("Wake losses have already been calculated with this model and settings.", "Continuum 3");
                    return;
                }
            }
            else
            {
                Close();
                return;
            }

            if (thisInst.turbineList.turbineEsts[0].EstsExistForWakeModel(thisInst.wakeModelList.wakeModels[wakeModelInd], thisInst.wakeModelList) == false)
            {
                BackgroundWork.Vars_for_TurbCalcs argsForBW = new BackgroundWork.Vars_for_TurbCalcs();

                if (thisInst.metList.ThisCount > 0)
                {
                    argsForBW.thisInst      = thisInst;
                    argsForBW.thisWakeModel = thisInst.wakeModelList.wakeModels[wakeModelInd];
                    argsForBW.MCP_Method    = thisInst.Get_MCP_Method();

                    // Call background worker to run calculations
                    thisInst.BW_worker = new BackgroundWork();
                    thisInst.BW_worker.Call_BW_TurbCalcs(argsForBW);
                    thisInst.ChangesMade();
                }
            }
            else
            {
                // Update Net turb tab
                Update updateThe = new Update();
                updateThe.NetTurbineEstsTAB(thisInst);
            }

            Close();
        }
Ejemplo n.º 2
0
        public void Maps_Waked()
        {
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();

            Continuum thisInst = new Continuum("");

            string fileName = saveFolder + "\\Maps_Waked";

            if (File.Exists(fileName + ".cfm"))
            {
                File.Delete(fileName + ".cfm");
                File.Delete(fileName + ".mdf");
                File.Delete(fileName + "_log.ldf");
            }

            thisInst.savedParams.savedFileName       = fileName + ".cfm";
            thisInst.UTM_conversions.savedDatumIndex = 0;
            thisInst.UTM_conversions.UTMZoneNumber   = 16;
            thisInst.UTM_conversions.hemisphere      = "Northern";

            thisInst.modeledHeight = 80;
            thisInst.SaveFile(true);

            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // Load topo data
            string topoFile = testingFolder + "\\Topo & LC\\Findlay\\Findlay Topo.tif";

            BackgroundWork.Vars_for_BW Vars_for_BW = new BackgroundWork.Vars_for_BW();
            Vars_for_BW.thisInst = thisInst;
            Vars_for_BW.Filename = topoFile;
            thisInst.BW_worker   = new BackgroundWork();
            thisInst.BW_worker.Call_BW_TopoImport(Vars_for_BW);

            while (thisInst.BW_worker.DoWorkDone == false && thisInst.BW_worker.WasReturned == false) // RunWorkerCompleted isn't getting called (?) so killing BW_Worker once it reaches end of DoWork
            {
                Thread.Sleep(1000);
            }

            if (thisInst.BW_worker.WasReturned)
            {
                Assert.Fail();
            }

            // Called in BackgroundWorker RunWorkerCompleted
            thisInst.SaveFile(true);
            thisInst.updateThe.AllTABs(thisInst);
            thisInst.BW_worker.Close();

            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // Load one met TAB file
            thisInst.metList.isTimeSeries = false;
            thisInst.ofdMets.FileName     = testingFolder + "\\Met TAB files\\Findlay\\Paulding Findlay coords.TAB";
            thisInst.ImportMetsTAB();

            // The following are all called in btnMetTAB_Click
            thisInst.turbineList.ClearAllWSEsts();
            thisInst.updateThe.AllTABs(thisInst);

            if (thisInst.topo.gotTopo == true)
            {
                if (thisInst.chkUseSR.Checked == true && thisInst.topo.gotSR == true)
                {
                    thisInst.topo.useSR = true;
                }
                else
                {
                    thisInst.topo.useSR = false;
                }

                if (thisInst.chk_Use_Sep.Checked == true)
                {
                    thisInst.topo.useSepMod = true;
                }
                else
                {
                    thisInst.topo.useSepMod = false;
                }

                // Call background worker to run calculations
                // In background worker, performs exposure and grid stat calculations, finds path of nodes and does site calibration.
                thisInst.BW_worker = new BackgroundWork();
                BackgroundWork.Vars_for_BW metArgs = new BackgroundWork.Vars_for_BW();
                metArgs.thisInst = thisInst;

                thisInst.BW_worker.Call_BW_MetCalcs(metArgs);

                while (thisInst.BW_worker.DoWorkDone == false && thisInst.BW_worker.WasReturned == false) // RunWorkerCompleted isn't getting called (?) so killing BW_Worker once it reaches end of DoWork
                {
                    Thread.Sleep(1000);
                }

                if (thisInst.BW_worker.WasReturned)
                {
                    Assert.Fail();
                }

                thisInst.SaveFile(true);
                thisInst.updateThe.AllTABs(thisInst);
                thisInst.BW_worker.Close();
            }

            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // Load one turbine
            string turbineFile = testingFolder + "\\Turbine sites\\Findlay\\Ball 2 Turbines.csv";

            thisInst.LoadTurbines(turbineFile);

            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // Analyze mets
            thisInst.BW_worker = new BackgroundWork();
            BackgroundWork.Vars_for_BW theArgs = new BackgroundWork.Vars_for_BW();
            theArgs.thisInst = thisInst;
            thisInst.BW_worker.Call_BW_MetCalcs(theArgs);

            while (thisInst.BW_worker.DoWorkDone == false && thisInst.BW_worker.WasReturned == false)
            {
                Thread.Sleep(1000);
            }

            if (thisInst.BW_worker.WasReturned)
            {
                Assert.Fail();
            }

            thisInst.BW_worker.Close();

            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // Generate turbine wind speed and gross energy estimates

            // First check that a model has been created
            if (thisInst.modelList.ModelCount == 0)
            {
                thisInst.Analyze_Mets();

                while (thisInst.BW_worker.DoWorkDone == false && thisInst.BW_worker.WasReturned == false)
                {
                    Thread.Sleep(1000);
                }

                if (thisInst.BW_worker.WasReturned)
                {
                    Assert.Fail();
                }

                thisInst.BW_worker.Close();
            }


            BackgroundWork.Vars_for_TurbCalcs argsForBW = new BackgroundWork.Vars_for_TurbCalcs();

            argsForBW.thisInst      = thisInst;
            argsForBW.thisWakeModel = null;

            // Call background worker to run calculations
            thisInst.BW_worker   = new BackgroundWork();
            MCP_Method           = thisInst.Get_MCP_Method();
            argsForBW.MCP_Method = MCP_Method;
            thisInst.BW_worker.Call_BW_TurbCalcs(argsForBW);

            while (thisInst.BW_worker.DoWorkDone == false && thisInst.BW_worker.WasReturned == false)
            {
                Thread.Sleep(100);
            }

            if (thisInst.BW_worker.WasReturned == true)
            {
                Assert.Fail();
            }

            Assert.AreNotEqual(thisInst.turbineList.turbineEsts[0].avgWS_Est[0].freeStream.WS, 0, "Didn't calculate average WS");

            thisInst.updateThe.AllTABs(thisInst);
            thisInst.BW_worker.Close();

            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // Load a power curve
            string powerCurveFile = testingFolder + "\\Power Curves\\GE_1_85_CRV.csv";

            thisInst.ofdPowerCurve.FileName = powerCurveFile;
            thisInst.turbineList.ImportPowerCurve(thisInst, 87, 16);

            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // Do Exceedance calcs
            // Delete 10 of the curves to speed up calcs
            for (int i = 0; i < 10; i++)
            {
                thisInst.turbineList.exceed.Delete_Exceed(thisInst.lstDefinedLosses.Items[i].Text);
            }

            // Reduce the number simulations to 1000
            thisInst.turbineList.exceed.numSims = 1000;

            BackgroundWork.Vars_for_BW varsForBW = new BackgroundWork.Vars_for_BW();
            varsForBW.thisInst = thisInst;
            thisInst.BW_worker = new BackgroundWork();
            thisInst.BW_worker.Call_BW_Exceed(varsForBW);

            while (thisInst.BW_worker.DoWorkDone == false && thisInst.BW_worker.WasReturned == false)
            {
                Thread.Sleep(100);
            }

            if (thisInst.BW_worker.WasReturned == true)
            {
                Assert.Fail();
            }

            Assert.AreEqual(thisInst.turbineList.exceed.compositeLoss.isComplete, true, "Didn't do Monte Carlo model");

            thisInst.updateThe.AllTABs(thisInst);
            thisInst.BW_worker.Close();

            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // Create Eddy Viscosity Wake Model
            Gen_WakeModel thisWake = new Gen_WakeModel(thisInst);

            thisWake.cboWakeCombo.SelectedIndex = 0;

            thisWake.cboWakeModel.SelectedIndex = 0;
            thisWake.cboPowerCrvs.SelectedIndex = 0;
            thisWake.txtHorizWakeExp.Text       = "5";
            thisWake.txtAmbTI.Text = "10";


            thisWake.GenWakeModel();

            while (thisInst.BW_worker.DoWorkDone == false && thisInst.BW_worker.WasReturned == false)
            {
                Thread.Sleep(100);
            }

            Assert.AreEqual(thisInst.wakeModelList.NumWakeModels, 1, "Didn't create a wake model");

            thisInst.updateThe.AllTABs(thisInst);
            thisInst.BW_worker.Close();


            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // Create wake map
            GenWakeMap wakeMap = new GenWakeMap(thisInst);

            numMaps = thisInst.wakeModelList.NumCompleteWakeGridMaps;
            wakeMap.cboWakeModels.Items.Clear();
            for (int i = 0; i <= thisInst.wakeModelList.NumWakeModels - 1; i++)
            {
                string Wake_String = thisInst.wakeModelList.CreateWakeModelString(thisInst.wakeModelList.wakeModels[i]);
                wakeMap.cboWakeModels.Items.Add(Wake_String);
            }

            wakeMap.cboWakeModels.SelectedIndex    = 0;
            wakeMap.cboUseTimeSeries.SelectedIndex = 0; // Use Avg Dist.
            wakeMap.gridReso = 250;
            wakeMap.UpdateLimits();
            wakeMap.GetCoordsAroundTurbs();
            wakeMap.GenerateWakeMap();

            while (thisInst.BW_worker.DoWorkDone == false)
            {
                Thread.Sleep(100);
            }

            thisInst.updateThe.AllTABs(thisInst);
            thisInst.BW_worker.Close();

            Assert.AreEqual(thisInst.wakeModelList.NumCompleteWakeGridMaps, numMaps + 1, "Didn't create waked map");

            thisInst.SaveFile(true);
            thisInst.Close();
        }