Esempio n. 1
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            //______________________________________________________________________________________________
            ////////////////////////////////        I N P U T S          ///////////////////////////////////
            Mesh            msh    = new Mesh();
            CObstacleObject mshobj = null;

            if (!DA.GetData(0, ref mshobj))
            {
                return;
            }
            msh = mshobj.mesh;

            //should containt analysis surface itself
            List <CObstacleObject> objObst = new List <CObstacleObject>();

            if (!DA.GetDataList(1, objObst))
            {
                return;
            }

            List <CPermObject> treeObst = new List <CPermObject>();

            DA.GetDataList(2, treeObst);

            double latitude = 0.0;

            if (!DA.GetData(4, ref latitude))
            {
                return;
            }
            double longitude = 0.0;

            if (!DA.GetData(5, ref longitude))
            {
                return;
            }

            int year = 0;

            if (!DA.GetData(6, ref year))
            {
                return;
            }

            double snow_threshold = 1.0;

            if (!DA.GetData(7, ref snow_threshold))
            {
                snow_threshold = 1.0;
            }
            double tilt_threshold = 60.0;

            if (!DA.GetData(8, ref tilt_threshold))
            {
                tilt_threshold = 60.0;
            }


            List <double> DNI = new List <double>();

            if (!DA.GetDataList(10, DNI))
            {
                return;
            }
            List <double> DHI = new List <double>();

            if (!DA.GetDataList(11, DHI))
            {
                return;
            }
            List <double> SNOW = new List <double>();

            if (!DA.GetDataList(12, SNOW))
            {
                for (int t = 0; t < 8760; t++)
                {
                    SNOW.Add(0.0);
                }
            }
            List <double> groundalbedo = new List <double>();

            if (!DA.GetDataList(13, groundalbedo))
            {
                for (int t = 0; t < 8760; t++)
                {
                    groundalbedo.Add(0.2);
                }
            }
            List <double> solarAzimuth = new List <double>();

            DA.GetDataList(14, solarAzimuth);
            List <double> solarAltitude = new List <double>();

            DA.GetDataList(15, solarAltitude);

            int MainSkyRes = 0;

            if (!DA.GetData(17, ref MainSkyRes))
            {
                MainSkyRes = 1;
            }
            int MainInterpMode = 0;

            if (!DA.GetData(18, ref MainInterpMode))
            {
                MainInterpMode = 0;
            }

            int SpecBounces = 1;

            if (!DA.GetData(20, ref SpecBounces))
            {
                SpecBounces = 1;
            }
            SpecBounces = (SpecBounces < 0) ? 0 : SpecBounces;
            int SpecInterpMode = 0;

            if (!DA.GetData(21, ref SpecInterpMode))
            {
                SpecInterpMode = 0;
            }

            int DiffIReflSkyRes = 0;

            if (!DA.GetData(23, ref DiffIReflSkyRes))
            {
                DiffIReflSkyRes = 0;
            }
            int DiffIReflSkyRes2nd = 0;

            if (!DA.GetData(24, ref DiffIReflSkyRes2nd))
            {
                DiffIReflSkyRes2nd = 0;
            }
            int DiffIReflMode = 1;

            if (!DA.GetData(25, ref DiffIReflMode))
            {
                DiffIReflMode = 1;
            }

            CResultsInterreflections ResultsIreflIn = null;

            DA.GetData(27, ref ResultsIreflIn);

            bool mt = false;

            if (!DA.GetData(29, ref mt))
            {
                mt = false;
            }
            ////////////////////////////////////////////////////////////////////////////////////////////////
            //______________________________________________________________________________________________


            //______________________________________________________________________________________________
            ////////////////////////////////        S I M U L A T E      ///////////////////////////////////
            CCalculateSolarMesh calc = new CCalculateSolarMesh(
                mshobj, objObst, treeObst, latitude, longitude, DNI, DHI, SNOW, groundalbedo, snow_threshold, tilt_threshold,
                year, null, mt, solarAzimuth, solarAltitude);

            calc.RunAnnualSimulation_MT(
                mshobj.tolerance, MainSkyRes, MainInterpMode, SpecBounces, SpecInterpMode, DiffIReflSkyRes, DiffIReflSkyRes2nd, DiffIReflMode);

            CResults results = calc.getResults();

            //cResultsInterreflections resultsIreflOut = calc.getResultsInterreflections();
            ////////////////////////////////////////////////////////////////////////////////////////////////
            //______________________________________________________________________________________________


            //______________________________________________________________________________________________
            ////////////////////////////////          O U T P U T        ///////////////////////////////////
            DA.SetData(0, results);

            ////////////////////////////////////////////////////////////////////////////////////////////////
            //______________________________________________________________________________________________


            Rhino.RhinoApp.WriteLine("SOLAR MODEL... Done");
        }
Esempio n. 2
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            #region INPUTS
            //___________________________________________________________________
            /////////////////////////////////////////////////////////////////////
            //INPUTS
            Mesh            msh    = new Mesh();
            CObstacleObject mshobj = null;
            if (!DA.GetData(0, ref mshobj))
            {
                return;
            }
            msh = mshobj.mesh;

            //should containt analysis surface itself
            List <CObstacleObject> objObst = new List <CObstacleObject>();
            if (!DA.GetDataList(1, objObst))
            {
                return;
            }

            List <CPermObject> treeObst = new List <CPermObject>();
            DA.GetDataList(2, treeObst);

            double latitude = 0.0;
            if (!DA.GetData(4, ref latitude))
            {
                return;
            }
            double longitude = 0.0;
            if (!DA.GetData(5, ref longitude))
            {
                return;
            }

            int year = 0;
            if (!DA.GetData(6, ref year))
            {
                return;
            }
            int month = 0;
            if (!DA.GetData(7, ref month))
            {
                return;
            }
            int day = 0;
            if (!DA.GetData(8, ref day))
            {
                return;
            }
            int hour = 0;
            if (!DA.GetData(9, ref hour))
            {
                return;
            }

            double snow_threshold = 1.0;
            if (!DA.GetData(10, ref snow_threshold))
            {
                snow_threshold = 1.0;
            }
            double tilt_threshold = 60.0;
            if (!DA.GetData(11, ref tilt_threshold))
            {
                tilt_threshold = 60.0;
            }


            List <double> DNI = new List <double>();
            if (!DA.GetDataList(13, DNI))
            {
                return;
            }
            List <double> DHI = new List <double>();
            if (!DA.GetDataList(14, DHI))
            {
                return;
            }
            List <double> SNOW = new List <double>();
            if (!DA.GetDataList(15, SNOW))
            {
                for (int t = 0; t < 8760; t++)
                {
                    SNOW.Add(0.0);
                }
            }
            List <double> groundalbedo = new List <double>();
            if (!DA.GetDataList(16, groundalbedo))
            {
                for (int t = 0; t < 8760; t++)
                {
                    groundalbedo.Add(0.2);
                }
            }
            List <double> solarAzimuth = new List <double>();
            DA.GetDataList(17, solarAzimuth);
            List <double> solarAltitude = new List <double>();
            DA.GetDataList(18, solarAltitude);


            int MainSkyRes = 0;
            if (!DA.GetData(20, ref MainSkyRes))
            {
                MainSkyRes = 1;
            }
            int SpecBounces = 1;
            if (!DA.GetData(21, ref SpecBounces))
            {
                SpecBounces = 1;
            }
            SpecBounces = (SpecBounces < 0) ? 0 : SpecBounces;
            int DiffIReflSkyRes = 0;
            if (!DA.GetData(22, ref DiffIReflSkyRes))
            {
                DiffIReflSkyRes = 0;
            }
            int DiffIReflSkyRes2nd = 0;
            if (!DA.GetData(23, ref DiffIReflSkyRes2nd))
            {
                DiffIReflSkyRes2nd = 0;
            }

            CResultsInterreflections ResultsIreflIn = null;
            DA.GetData(25, ref ResultsIreflIn);

            bool mt = false;
            if (!DA.GetData(27, ref mt))
            {
                mt = false;
            }

            int timezone = 0;
            DA.GetData(28, ref timezone);

            /////////////////////////////////////////////////////////////////////
            //___________________________________________________________________
            #endregion



            #region SIMULATE
            //______________________________________________________________________________________________
            ////////////////////////////////        S I M U L A T E      ///////////////////////////////////
            CCalculateSolarMesh calc = new CCalculateSolarMesh(
                mshobj, objObst, treeObst, latitude, longitude, DNI, DHI, SNOW, groundalbedo, snow_threshold,
                tilt_threshold, year, null, mt, solarAzimuth, solarAltitude, timezone);
            calc.RunHourSimulationMT(month, day, hour, MainSkyRes, SpecBounces, DiffIReflSkyRes, DiffIReflSkyRes2nd);
            Line     ln      = calc.getSolarVec();
            CResults results = calc.getResults();
            CResultsInterreflections resultsIreflOut = calc.getResultsInterreflections();
            ////////////////////////////////////////////////////////////////////////////////////////////////
            //______________________________________________________________________________________________
            #endregion



            #region OUTPUT
            //______________________________________________________________________________________________
            ////////////////////////////////          O U T P U T        ///////////////////////////////////
            DA.SetData(0, ln);
            DA.SetData(1, results);
            DA.SetData(2, resultsIreflOut);
            ////////////////////////////////////////////////////////////////////////////////////////////////
            //______________________________________________________________________________________________
            #endregion
        }