Ejemplo n.º 1
0
        public EnergyPlusAdapter(BH.oM.Adapter.FileSettings fileSettings, EnergyPlusSettings settings = null)
        {
            m_AdapterSettings.DefaultPushType = oM.Adapter.PushType.CreateOnly;

            FileSettings = fileSettings;
            _settings    = settings ?? new EnergyPlusSettings();

            if (!Path.HasExtension(fileSettings.FileName) || Path.GetExtension(fileSettings.FileName) != ".idf")
            {
                BH.Engine.Base.Compute.RecordError("File Name must contain a file extension");
                return;
            }
        }
Ejemplo n.º 2
0
        public static bool SimulateIDF(EnergyPlusSettings energyPlusSettings, string idfFile, bool run = false)
        {
            // Clear existing files to prevent re-use of these in simulation
            List <string> toDelete = new List <string>()
            {
                "audit", "bnd", "csv", "dbg", "eio", "end", "err", "eso", "mtd", "mtr", "rdd", "shd"
            };

            foreach (string ext in toDelete)
            {
                foreach (string f in Directory.EnumerateFiles(energyPlusSettings.ProjectDirectory, String.Format("{0}.{1}", energyPlusSettings.ProjectName, ext)))
                {
                    File.Delete(f);
                }
            }

            // Construct full run-command
            string formatString  = "{0} -r -x -d {1} -p {2} -w {3} {4}";
            string commandString = String.Format(formatString, energyPlusSettings.EnergyPlusExecutable, energyPlusSettings.ProjectDirectory, energyPlusSettings.ProjectName, energyPlusSettings.WeatherFile, idfFile);

            bool success;

            if (run)
            {
                success = RunCommand(commandString);
                if (success)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }