bsl546 / energym

Energym is an open source building simulation library designed to test climate control and energy management strategies on buildings in a systematic and reproducible way.
Other
64 stars 11 forks source link

Adding new models #6

Open LorenzoBottaccioli opened 2 years ago

LorenzoBottaccioli commented 2 years ago

Dear,

Thanks for your great work. I'm trying to add new models to the environment but after compiling the FMU it is unclear how to use it. By reading a little bit of the code of the existing ones I have understood that I have to create a enviromnet.py script but is completely unclear how to and in particular how to add it to the factory.py script that is the one in charge of doing the make command. Could you provide some guidelines for it or a tutorial?

Thanks a lot

psh987 commented 2 years ago

Dear Lorenzo, thanks for your interest in Energym! It's a good idea to provide a full tutorial, we will do that, but it might take a while. In the meantime, here are the most important steps:

  1. add your model in the simulation folder in the appropriate category (EnergyPlus or Modelica)
  2. create a folder in energym.envs with the name of your model with an init.py and environment.py in it.
  3. in the environment.py, you have to specify the inputs and outputs as dictionaries, in the INPUTS_SPECS and OUTPUTS_SPECS, and the default kpi options (also as dictionary)
  4. To create a class for your model, either subclass EnvEPlusFMU (if your model is EnergyPlus based) or EnvModFMU (if your model is Modelica based)
  5. Specify fixed attributes of your model (like simulation step size) in the class and pass the flexible attributes (like the simulation start time) in the init.
  6. add the name of your model to the EnvNames enum in env_names.py
  7. import your class in factory.py
  8. in the make function, filter for the name you specified in EnvNames and create one instantiation for the case of the evaluation mode (everything should be fixed there), and one for the normal mode (considering passed keyword arguments in make)

I hope the steps make sense, and I think it is helpful to pick one of the available models to compare how the steps are done there. If you have any questions, feel free to reach out anytime!