Question-and-Answer Resource for the Building Energy Modeling Community
Get started with the Help page
Ask Your Question
1

Start Simulation For ThermalZone With IdealLoadsAirSystem In C#

asked 2022-08-27 08:42:19 -0500

updated 2023-04-17 07:13:41 -0500

hello to all friend, I have created a simple example consisting of a thermal zone with door and window. Also, I have considered an ideal system for it, I have created the osm file, now I want to get the energy simulation as well as the calculation of the thermal and cooling loads of the system for this thermal zone, which class should I use to Start perform the simulation ?

I wrote the following code to analyze the model that I have attached the osm file But at the time of execution, it gets an error from modelmeasure For modelmeasure, it is not possible to create a manufacturer, thank you for your guidance

OpenStudio.WorkflowJSON workflowJSON = new OpenStudio.WorkflowJSON();
OpenStudio.Workspace workspace = new OpenStudio.Workspace();
OpenStudio.OSArgumentVector arguments = new OpenStudio.OSArgumentVector();
OpenStudio.OSArgumentMap argumentmap = new OpenStudio.OSArgumentMap();
OpenStudio.OSRunner oSRunner = new OpenStudio.OSRunner(workflowJSON);
oSRunner.setLastOpenStudioModel(this.Model);
oSRunner.validateUserArguments(arguments, argumentmap);
oSRunner.setLastEnergyPlusWorkspace(workspace);                     
oSRunner.registerFinalCondition("Generated report");
oSRunner.registerInitialCondition("");

OpenStudio.ModelMeasure modelMeasure = null;
modelMeasure.run(this.Model, oSRunner, argumentmap);
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
3

answered 2022-08-30 04:28:07 -0500

updated 2022-08-30 04:29:20 -0500

You need to make a system call to the openstudio CLI. openstudio.exe run -w workflow.osw. Your workflow.osw can be as simple as:

{
   "seed_file" : "../model.osm",
   "weather_file" : "USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw"
}

The OpenStudioApplication can also be used to configure your model / weather file, add measures etc, and it will create a workflow.osw in the model companion directory (= if you have a file called mymodel.osm you will find a folder next to it called mymodel/ and inside at mymodel/workflow.osw you have the workflow file). This is helpful to see what a valid workflow.osw looks like.


$ openstudio.exe run --help

Usage: openstudio run [options]

Options:

    -w, --workflow [FILE]            Specify the FILE path to the workflow to run
    -m, --measures_only              Only run the OpenStudio and EnergyPlus measures
    -p, --postprocess_only           Only run the reporting measures
        --export-epJSON              export epJSON file format. The default is IDF
    -s, --socket PORT                Pipe status messages to a socket on localhost PORT
        --show-stdout                Prints the output of the workflow run in real time to the console, including E+ output
        --debug                      Includes additional outputs for debugging failing workflows and does not clean up the run directory

Forward Translator Options:
        --[no-]runcontrolspecialdays Include RunControlSpecialDays (Holidays) [Default: True]
        --set-ip-tabular-output      Request IP units from E+ Tabular (HTML) Report [Default: False]
        --[no-]lifecyclecosts        Include LifeCycleCosts [Default: True]
        --[no-]sqlite-output         Request Output:SQLite from E+ [Default: True]
        --[no-]html-output           Request Output:Table:SummaryReports report from E+ [Default: True]
        --[no-]space-translation     Add individual E+ Space [Default: True]

Stdout Options: only available when --show-stdout is passed
        --add-timings                Print the start, end and elapsed times of each state of the simulation.
        --style-stdout               Style the stdout output to more clearly show the start and end of each state of the simulation

    -h, --help                       Print this help
edit flag offensive delete link more

Comments

Thank you very much for your help, I made this model with C#, I was also able to create a file with the extension osm or idf from my model, I want all the steps to be done in C#; Which class in C# creates work flow? I just checked, there is a class called JSON Workflows in the openstudio library. After the workflow is created, how is the simulation process created? I realized that I need to create a runner, as well as a workflow. Then I give the model and workflow to the runner to start the simulation

Masoud's avatar Masoud  ( 2022-08-30 05:15:20 -0500 )edit
1

answered 2022-09-04 02:29:39 -0500

updated 2022-09-05 07:19:42 -0500

With the help of Julien, I was able to write the following code and my problem was solved

OpenStudio.WorkflowJSON workflowJSON = new OpenStudio.WorkflowJSON();
workflowJSON.setSeedFile(new OpenStudio.Path(OpenStudio.OpenStudioUtilitiesCore.toPath(OsmPath)));
workflowJSON.setWeatherFile(new OpenStudio.Path(OpenStudio.OpenStudioUtilitiesCore.toPath("D:\\Pluginet\\Chiral\\Chiral\\WeatherFile\\IRN_Shiraz.408480_ITMY.epw")));
workflowJSON.saveAs(new OpenStudio.Path(OpenStudio.OpenStudioUtilitiesCore.toPath(OswPath)));
System.Diagnostics.Process.Start("cmd.exe", "/C openstudio.exe run -w " + OswPath);
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Careers

Question Tools

1 follower

Stats

Asked: 2022-08-27 08:38:09 -0500

Seen: 276 times

Last updated: Jun 23 '23