GithubHelp home page GithubHelp logo

spawn's Introduction

Spawn

Spawn is a software package for performing co-simulations involving EnergyPlus and Modelica. This package bundles the following items in one self contained package.

  1. A method for connecting EnergyPlus models to Modelica
  2. A Modelica compiler toolchain for compiling and running Modelica models
  3. Modelica libraries and content, including the Modelica Buildings Library (MBL) and the Modelica Standard Library.

The Spawn installation package is fully self contained, and there are no external third party dependencies. Together the capabilities in this package, provide a single integrated environment for performing hybrid Modelica and EnergyPlus simulations. The primary entry point is the spawn command line interface.

Installation

Binary packages are published on GitHub, https://github.com/NREL/Spawn/releases. Extract the package to a location of your choosing and optionally put the bin/spawn executable in your system path.

Additional computer platforms, including versions of Mac OS and Windows will be supported in future releases.

Example Usage

Detailed help is built into the command line program spawn --help.

  • Compile a Modelica model. Models contained with the Modelica Buildings Library and the Modelica Standard Library are included and available to the compiler by default.
spawn modelica create-exe Buildings.Examples.Tutorial.Boiler.System1
  • Compile and run a Modelica model, which internally leverages EnergyPlus.
spawn modelica simulate Buildings.ThermalZones.EnergyPlus.Validation.ThermalZone.OneZoneOneYear

Compiling Spawn from source

apt install libllvm10 llvm-10-dev clang-10 libclang-10-dev liblld-10-dev liblld-10-dev gfortran
pip install conan
  • If neccessary add variables to locate llvm and clang. (not required for apt-get installed linux packages)
export LLVM_DIR=/path/to/llvm/
export Clang_DIR=/path/to/clang/
  • Then follow the normal cmake build process.
git clone --recurse-submodules https://github.com/NREL/spawn.git
cd spawn
mkdir build
cd build
cmake ../
make -j

spawn's People

Contributors

jmythms avatar kbenne avatar lefticus avatar mwetter avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

spawn's Issues

Support for GroundHeatTransfer:Slab object

It seems that the Spawn has not supported the EnergyPlus idf file with GroundHeatTransfer:Slab modules. Are there any plans for adding this in? The DOE residential prototype buildings have these modules.

Remove start attribute that is not allowed in modelDescription.xml

The surface object uses the following xml entry:

<ScalarVariable name="Living:Floor_Q_flow" valueReference="13"
  description="Net heat flow rate ...."
  causality="output" variability="continuous" initial="calculated">
  <Real quantity="Power" relativeQuantity="false" start="0.0" unit="W" />
</ScalarVariable>

This cause

[ERROR][FMI2XML] Start attribute is not allowed for variables with initial='calculated'
[WARNING][FMI2XML] Attribute 'start' not processed by element 'Real' handle

when importing the FMU.

MODELON_LICENSE_PATH not set

Hi,

Using the latest binaries on Ubuntu 22.04 ("Spawn-0.4.1-aa189fef75-Ubuntu22.04.tar.gz"), I am trying to compile an FMU as per the commands given in "Example Usage":

  • spawn modelica --create-fmu Buildings.Examples.Tutorial.Boiler.System1

However, this crashes with the following error:

Compiling Model with Optimica
Parse Model
Trouble during Optimica Compiling
1 errors found:

Error:
Could not verify license
Cause: MODELON_LICENSE_PATH not set.


Compile C Code
Spawn encountered an error:
"Error parsing xml document located at : /home/marius/Desktop/spawn/examples/Buildings_Examples_Tutorial_Boiler_System1/modelDescription.xml"

So if I understand correctly, one needs to obtain a license for OCT from Modeleon to get this feature working currently?

Best regards,
Marius

exeDir() is not robust

There are a variety of circumstances where the spawn cli needs to know where it is located in order to find supporting resources. The current logic to perform this function is here

fs::path exedir() {
. The problem is that this is not robust for some cases including at least

  1. Spawn is installed into the system PATH and is invoked from the command line generically as spawn. (no full path)
  2. The spawn cli is called from a link.

It might be that 1 and 2 may exist. At least on Linux Spawn is not robust to these cases.

Flesh out c bridge implementation

The current implementation of c bridge has stubs for many of the c standard library functions. We need to flesh these out enough to compile Modelica generated C code.

@kbenne will need to provide example source that needs to be supported by the compiler.

FMU Zone volume mismatch

Hello,

I am doing simulation using the Buildings.ThermalZones.EnergyPlus_9_6_0.Examples.SingleFamilyHouse.AirHeating model. Since I am using a different idf file, I changed the the assignment for AFlo and VRoo in the AirHeating model (using the values from my EnergyPlus output file) to reflect the volume that my EnergyPlus model has as shown below

image

But I am getting the Error:
Zone volume VRoo differs from volume returned by EnergyPlus.
Failed condition: abs(960.74-building_FDD.zon.V) < 0.01

I noticed that this error is specifically with VRoo, so I do not understand why there is discrepancy in the energyplus output file (960.74m3) and what the fmu is returning (422.16m3).

Below are the idf files I tested with. Interesting, the Miami idf file works correctly, but the other two does not, so I do not understand why.

EP_models.zip

I will deeply appreciate any help that can be rendered to resolve this problem.

FMU binary file permissions

Please make the file permission of the executables located in the binary directory 755, otherwise some containerized workflows do not work correctly.

Add simulation capability

Spawn contains functions to generate an EnergyPlus FMU, and also functions to compile modelica content, however there is no built in capability to actually simulate the resulting model.

This purpose of this issue is to add a simulation function to Spawn.

llvm / clang linking to shared libs

Hey @lefticus

I noticed that the cmake rules are linking to the llvm and clang shared libraries. This isn't the end of the world. I could use fixup_bundle to install these with our end user distribution package. But I would prefer to link to the archive libraries.

I think the issue stems from these link commands

clangBasic
. We are using the llvm provided cmake export libraries and those targets currently map to the shared libs. I wonder if there are alternative export lib targets for the archive libraries, or if we can configure how this works with a flag.

I parsed through llvm-8's lib directory and the archive libs are certainly there, but I think it might be that one shared lib maps to many archives.

Do you think you could research this?

Error in './spawn': double free or corruption (!prev)

So, I need to compile spawn in order to have it run on ancient RHEL7 - as the releases you distribute depend on GLIBC > 2.25, and RHEL is only GLIBC 2.17. Compilation of tag v0.2.1 works, but I run into the following runtime error:

*** Error in './spawn': double free or corruption (!prev): 0x00000000035988c0 ***

And here I get a little bit stuck. You can see the full dump from the error below.

Kudos on a cool project - really hoping I can get this to work!


$ ./spawn

*** Error in './spawn': double free or corruption (!prev): 0x00000000035988c0 ***
======= Backtrace: =========
/lib64/libc.so.6(+0x81299)[0x2aaab019c299]
/lib64/libc.so.6(__cxa_finalize+0x9a)[0x2aaab015505a]
/home/u101337/Spawn-light-0.2.1-5d127d5774-Linux/bin/../lib/libenergyplusapi.so.9.5.0(+0xaa8fa3)[0x2aaaabcd5fa3]
======= Memory map: ========
00400000-00598000 r--p 00000000 00:2c 16377000427503977893 /home/u101337/Spawn-light-0.2.1-5d127d5774-Linux/bin/spawn-0.2.1-5d127d5774
00598000-02c7c000 r-xp 00198000 00:2c 16377000427503977893 /home/u101337/Spawn-light-0.2.1-5d127d5774-Linux/bin/spawn-0.2.1-5d127d5774
02c7c000-034e1000 r--p 0287c000 00:2c 16377000427503977893 /home/u101337/Spawn-light-0.2.1-5d127d5774-Linux/bin/spawn-0.2.1-5d127d5774
034e1000-03521000 r--p 030e0000 00:2c 16377000427503977893 /home/u101337/Spawn-light-0.2.1-5d127d5774-Linux/bin/spawn-0.2.1-5d127d5774
03521000-03527000 rw-p 03120000 00:2c 16377000427503977893 /home/u101337/Spawn-light-0.2.1-5d127d5774-Linux/bin/spawn-0.2.1-5d127d5774
03527000-035b9000 rw-p 00000000 00:00 0 [heap]
2aaaaaaab000-2aaaaaacd000 r-xp 00000000 08:13 11153053 /usr/lib64/ld-2.17.so
2aaaaaacd000-2aaaaaacf000 r-xp 00000000 00:00 0 [vdso]
2aaaaaacf000-2aaaaaad2000 rw-p 00000000 00:00 0
2aaaaaaf4000-2aaaaab01000 rw-p 00000000 00:00 0
2aaaaaccc000-2aaaaaccd000 r--p 00021000 08:13 11153053 /usr/lib64/ld-2.17.so
2aaaaaccd000-2aaaaacce000 rw-p 00022000 08:13 11153053 /usr/lib64/ld-2.17.so
2aaaaacce000-2aaaaaccf000 rw-p 00000000 00:00 0
2aaaaaccf000-2aaaaacd1000 r-xp 00000000 08:13 11154507 /usr/lib64/libdlfaker.so
2aaaaacd1000-2aaaaaed0000 ---p 00002000 08:13 11154507 /usr/lib64/libdlfaker.so
2aaaaaed0000-2aaaaaed1000 rw-p 00001000 08:13 11154507 /usr/lib64/libdlfaker.so
2aaaaaed1000-2aaaaaff4000 r-xp 00000000 08:13 11157580 /usr/lib64/libvglfaker.so
2aaaaaff4000-2aaaab1f3000 ---p 00123000 08:13 11157580 /usr/lib64/libvglfaker.so
2aaaab1f3000-2aaaab1f9000 rw-p 00122000 08:13 11157580 /usr/lib64/libvglfaker.so
2aaaab1f9000-2aaaab22d000 rw-p 00000000 00:00 0
2aaaab22d000-2aaaaed7e000 r-xp 00000000 00:2c 15396952036074685557 /home/u101337/Spawn-light-0.2.1-5d127d5774-Linux/lib/libenergyplusapi.so.9.5.0
2aaaaed7e000-2aaaaef7d000 ---p 03b51000 00:2c 15396952036074685557 /home/u101337/Spawn-light-0.2.1-5d127d5774-Linux/lib/libenergyplusapi.so.9.5.0
2aaaaef7d000-2aaaaefcd000 r--p 03b50000 00:2c 15396952036074685557 /home/u101337/Spawn-light-0.2.1-5d127d5774-Linux/lib/libenergyplusapi.so.9.5.0
2aaaaefcd000-2aaaaeff2000 rw-p 03ba0000 00:2c 15396952036074685557 /home/u101337/Spawn-light-0.2.1-5d127d5774-Linux/lib/libenergyplusapi.so.9.5.0
2aaaaeff2000-2aaaaf009000 rw-p 00000000 00:00 0
2aaaaf009000-2aaaaf020000 r-xp 00000000 08:13 11156610 /usr/lib64/libpthread-2.17.so
2aaaaf020000-2aaaaf21f000 ---p 00017000 08:13 11156610 /usr/lib64/libpthread-2.17.so
2aaaaf21f000-2aaaaf220000 r--p 00016000 08:13 11156610 /usr/lib64/libpthread-2.17.so
2aaaaf220000-2aaaaf221000 rw-p 00017000 08:13 11156610 /usr/lib64/libpthread-2.17.so
2aaaaf221000-2aaaaf225000 rw-p 00000000 00:00 0
2aaaaf225000-2aaaaf227000 r-xp 00000000 08:13 11154276 /usr/lib64/libdl-2.17.so
2aaaaf227000-2aaaaf427000 ---p 00002000 08:13 11154276 /usr/lib64/libdl-2.17.so
2aaaaf427000-2aaaaf428000 r--p 00002000 08:13 11154276 /usr/lib64/libdl-2.17.so
2aaaaf428000-2aaaaf429000 rw-p 00003000 08:13 11154276 /usr/lib64/libdl-2.17.so
2aaaaf429000-2aaaaf5e6000 r-xp 00000000 00:2c 5352867457449803337 /beegfs/apps/gcc/10.2.0/lib64/libstdc++.so.6.0.28
2aaaaf5e6000-2aaaaf7e5000 ---p 001bd000 00:2c 5352867457449803337 /beegfs/apps/gcc/10.2.0/lib64/libstdc++.so.6.0.28
2aaaaf7e5000-2aaaaf7f0000 r--p 001bc000 00:2c 5352867457449803337 /beegfs/apps/gcc/10.2.0/lib64/libstdc++.so.6.0.28
2aaaaf7f0000-2aaaaf7f3000 rw-p 001c7000 00:2c 5352867457449803337 /beegfs/apps/gcc/10.2.0/lib64/libstdc++.so.6.0.28
2aaaaf7f3000-2aaaaf7f6000 rw-p 00000000 00:00 0
2aaaaf7f6000-2aaaaf7f8000 r-xp 00000000 08:13 11155096 /usr/lib64/libutil-2.17.so
2aaaaf7f8000-2aaaaf9f7000 ---p 00002000 08:13 11155096 /usr/lib64/libutil-2.17.so
2aaaaf9f7000-2aaaaf9f8000 r--p 00001000 08:13 11155096 /usr/lib64/libutil-2.17.so
2aaaaf9f8000-2aaaaf9f9000 rw-p 00002000 08:13 11155096 /usr/lib64/libutil-2.17.so
2aaaaf9f9000-2aaaafa00000 r-xp 00000000 08:13 11154936 /usr/lib64/librt-2.17.so
2aaaafa00000-2aaaafbff000 ---p 00007000 08:13 11154936 /usr/lib64/librt-2.17.so
2aaaafbff000-2aaaafc00000 r--p 00006000 08:13 11154936 /usr/lib64/librt-2.17.so
2aaaafc00000-2aaaafc01000 rw-p 00007000 08:13 11154936 /usr/lib64/librt-2.17.so
2aaaafc01000-2aaaafd02000 r-xp 00000000 08:13 11154832 /usr/lib64/libm-2.17.so
2aaaafd02000-2aaaaff01000 ---p 00101000 08:13 11154832 /usr/lib64/libm-2.17.so
2aaaaff01000-2aaaaff02000 r--p 00100000 08:13 11154832 /usr/lib64/libm-2.17.so
2aaaaff02000-2aaaaff03000 rw-p 00101000 08:13 11154832 /usr/lib64/libm-2.17.so
2aaaaff03000-2aaaaff1a000 r-xp 00000000 00:2c 16647705671592783968 /beegfs/apps/gcc/10.2.0/lib64/libgcc_s.so.1
2aaaaff1a000-2aaab0119000 ---p 00017000 00:2c 16647705671592783968 /beegfs/apps/gcc/10.2.0/lib64/libgcc_s.so.1
2aaab0119000-2aaab011a000 r--p 00016000 00:2c 16647705671592783968 /beegfs/apps/gcc/10.2.0/lib64/libgcc_s.so.1
2aaab011a000-2aaab011b000 rw-p 00017000 00:2c 16647705671592783968 /beegfs/apps/gcc/10.2.0/lib64/libgcc_s.so.1
2aaab011b000-2aaab02df000 r-xp 00000000 08:13 11154214 /usr/lib64/libc-2.17.so
2aaab02df000-2aaab04de000 ---p 001c4000 08:13 11154214 /usr/lib64/libc-2.17.so
2aaab04de000-2aaab04e2000 r--p 001c3000 08:13 11154214 /usr/lib64/libc-2.17.so
2aaab04e2000-2aaab04e4000 rw-p 001c7000 08:13 11154214 /usr/lib64/libc-2.17.so
2aaab04e4000-2aaab04e9000 rw-p 00000000 00:00 0
2aaab04e9000-2aaab055a000 r-xp 00000000 08:13 11154066 /usr/lib64/libGL.so.1.7.0
2aaab055a000-2aaab0759000 ---p 00071000 08:13 11154066 /usr/lib64/libGL.so.1.7.0
2aaab0759000-2aaab0773000 r--p 00070000 08:13 11154066 /usr/lib64/libGL.so.1.7.0
2aaab0773000-2aaab0774000 rw-p 0008a000 08:13 11154066 /usr/lib64/libGL.so.1.7.0
2aaab0774000-2aaab0775000 rw-p 00000000 00:00 0
2aaab0775000-2aaab0779000 r-xp 00000000 08:13 11154150 /usr/lib64/libXv.so.1.0.0
2aaab0779000-2aaab0978000 ---p 00004000 08:13 11154150 /usr/lib64/libXv.so.1.0.0
2aaab0978000-2aaab0979000 r--p 00003000 08:13 11154150 /usr/lib64/libXv.so.1.0.0
2aaab0979000-2aaab097a000 rw-p 00004000 08:13 11154150 /usr/lib64/libXv.so.1.0.0
2aaab097a000-2aaab0ab2000 r-xp 00000000 08:13 11154124 /usr/lib64/libX11.so.6.3.0
2aaab0ab2000-2aaab0cb2000 ---p 00138000 08:13 11154124 /usr/lib64/libX11.so.6.3.0
2aaab0cb2000-2aaab0cb3000 r--p 00138000 08:13 11154124 /usr/lib64/libX11.so.6.3.0
2aaab0cb3000-2aaab0cb8000 rw-p 00139000 08:13 11154124 /usr/lib64/libX11.so.6.3.0
2aaab0cb8000-2aaab0cc9000 r-xp 00000000 08:13 11154133 /usr/lib64/libXext.so.6.4.0
2aaab0cc9000-2aaab0ec8000 ---p 00011000 08:13 11154133 /usr/lib64/libXext.so.6.4.0
2aaab0ec8000-2aaab0ec9000 r--p 00010000 08:13 11154133 /usr/lib64/libXext.so.6.4.0
2aaab0ec9000-2aaab0eca000 rw-p 00011000 08:13 11154133 /usr/lib64/libXext.so.6.4.0
2aaab0eca000-2aaab0eda000 r-xp 00000000 08:13 11154072 /usr/lib64/libGLX.so.0.0.0
2aaab0eda000-2aaab10da000 ---p 00010000 08:13 11154072 /usr/lib64/libGLX.so.0.0.0
2aaab10da000-2aaab10db000 r--p 00010000 08:13 11154072 /usr/lib64/libGLX.so.0.0.0
2aaab10db000-2aaab10dc000 rw-p 00011000 08:13 11154072 /usr/lib64/libGLX.so.0.0.0
2aaab10dc000-2aaab10fc000 rw-p 00000000 00:00 0
2aaab10fc000-2aaab116a000 r-xp 00000000 08:13 11154075 /usr/lib64/libGLdispatch.so.0.0.0
2aaab116a000-2aaab1369000 ---p 0006e000 08:13 11154075 /usr/lib64/libGLdispatch.so.0.0.0
2aaab1369000-2aaab1391000 r--p 0006d000 08:13 11154075 /usr/lib64/libGLdispatch.so.0.0.0
2aaab1391000-2aaab1392000 rw-p 00095000 08:13 11154075 /usr/lib64/libGLdispatch.so.0.0.0
2aaab1392000-2aaab13b2000 rw-p 00000000 00:00 0
2aaab13b2000-2aaab13d9000 r-xp 00000000 08:13 11155289 /usr/lib64/libxcb.so.1.1.0
2aaab13d9000-2aaab15d8000 ---p 00027000 08:13 11155289 /usr/lib64/libxcb.so.1.1.0
2aaab15d8000-2aaab15d9000 r--p 00026000 08:13 11155289 /usr/lib64/libxcb.so.1.1.0
2aaab15d9000-2aaab15da000 rw-p 00027000 08:13 11155289 /usr/lib64/libxcb.so.1.1.0
2aaab15da000-2aaab15dc000 r-xp 00000000 08:13 11154126 /usr/lib64/libXau.so.6.0.0
2aaab15dc000-2aaab17dc000 ---p 00002000 08:13 11154126 /usr/lib64/libXau.so.6.0.0
2aaab17dc000-2aaab17dd000 r--p 00002000 08:13 11154126 /usr/lib64/libXau.so.6.0.0
2aaab17dd000-2aaab17de000 rw-p 00003000 08:13 11154126 /usr/lib64/libXau.so.6.0.0
2aaab4000000-2aaab4021000 rw-p 00000000 00:00 0
2aaab4021000-2aaab8000000 ---p 00000000 00:00 0
7ffffffdc000-7ffffffff000 rw-p 00000000 00:00 0 [stack]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]
Aborted (core dumped)

Update warmup convergence check.

EnergyPlus conventionally uses the zone air temperature as the metric for warmup convergence. In Spawn we would like to enhance this to also use the wall temperature as another metric for convergence.

Mac OS X (Apple Sillicon) support

I have managed to get part of the way in getting Spawn running on a MacBook w. M2 processor.
I can compile a working spawn w/o compiler toolchain embedded with a few changes to CMake files + compilation of the EnergyPlus and pyfmi dependencies.

However, for it to be super useful for me, I would love to see the compiler toolchain embedded, since then I can short-circuit e.g. Dymola which does not provide Mac (and/or ARM) builds 👎 , and at least compile FMUs for simulations/control development purposes. This would be a killer setup - and super useful to have a cli tool to build FMUs without relying on Dymola...

I get the following errors in c_compiler/compiler.cpp, but looking at the file I can see that this is def. where work is needed to get it running on Mac OS X w. Apple Sillicon 🥲 :

builds/spawn/c_compiler/compiler.cpp:317:20: error: no member named 'elf' in namespace 'lld' [clang-diagnostic-error]
  317 |     success = lld::elf::link(Args, false /*canExitEarly*/, out, err);

builds/spawn/c_compiler/compiler.cpp:291:23: error: object of type 'ErrorHandler' cannot be assigned because its copy assignment operator is implicitly deleted [clang-diagnostic-error]
  291 |   lld::errorHandler() = lld::ErrorHandler{};

Segmentation fault when simulation stops after first call to fmi2GetReal

It appears that version da220b3 has a bug that causes a segmentation fault.

Models run fine if there is no error. However, when debugging a wrong input for the surface temperature (setting it mistakenly to 0 Kelving which E+ seems to reject with an error) I got Optimica and Dymola into a segmentation fault.

I can now reproduce this with a basic test in which I run a model with only a room (no setting of the surface temperature) as
jm_ipython.sh jmodelica.py Buildings.ThermalZones.EnergyPlus.Validation.ThermalZone.OneZone
The model computes fine. However, if I add

$ git diff Buildings/Resources/src/ThermalZones/EnergyPlus/C-Sources/SpawnObjectInstantiate.c
diff --git a/Buildings/Resources/src/ThermalZones/EnergyPlus/C-Sources/SpawnObjectInstantiate.c b/Buildings/Resources/src/ThermalZones/EnergyPlus/C-Sources/SpawnObjectInstantiate.c
index dc72c17f63..653d8f3cc1 100644
--- a/Buildings/Resources/src/ThermalZones/EnergyPlus/C-Sources/SpawnObjectInstantiate.c
+++ b/Buildings/Resources/src/ThermalZones/EnergyPlus/C-Sources/SpawnObjectInstantiate.c
@@ -49,6 +49,7 @@ void EnergyPlusSpawnInitialize(
     bui->SpawnFormatMessage("%.3f %s: Getting parameters from EnergyPlus, bui at %p, Spawn object at %p, parameter at %p.\n", bui->time, ptrSpaObj->modelicaName,
       bui, ptrSpaObj, ptrSpaObj->parameters);
   getVariables(bui, modelicaName, ptrSpaObj->parameters);
+  bui->SpawnFormatError("fixme 3: Got to here %s.", modelicaName);
 
   /* Assign nObj to synchronize all Spawn objects of this building */
   *nObj = (int)bui->nExcObj;

I get

Warming up {5}
Warming up {6}
Starting Simulation at 01/01/2017 for SPAWN-RUNPERIOD
---------------------------------------------------------------------------
FMUException                              Traceback (most recent call last)
~/prg/windows-virtualbox-shared/modelica-buildings/jmodelica.py in <module>
    114   print(f"Solver is {opts['solver']}, {rtol}")
    115 
--> 116 res = mod.simulate(options=opts)
    117 #        logging.error(traceback.format_exc())
    118 

src/pyfmi/fmi.pyx in pyfmi.fmi.FMUModelME2.simulate()

src/pyfmi/fmi.pyx in pyfmi.fmi.ModelBase._exec_simulate_algorithm()

src/pyfmi/fmi.pyx in pyfmi.fmi.ModelBase._exec_simulate_algorithm()

/opt/oct/Python/pyfmi/fmi_algorithm_drivers.py in __init__(self, start_time, final_time, input, model, options)
    316             elif isinstance(self.model, fmi.FMUModelME2) or isinstance(self.model, fmi_coupled.CoupledFMUModelME2):
    317                 self.model.setup_experiment(tolerance=rtol, start_time=self.start_time, stop_time=self.final_time)
--> 318                 self.model.initialize()
    319                 self.model.event_update()
    320                 self.model.enter_continuous_time_mode()

src/pyfmi/fmi.pyx in pyfmi.fmi.FMUModelBase2.initialize()

src/pyfmi/fmi.pyx in pyfmi.fmi.FMUModelBase2.initialize()

src/pyfmi/fmi.pyx in pyfmi.fmi.FMUModelBase2.enter_initialization_mode()

FMUException: Enter Initialize returned with an error. Enable logging for more information, (load_fmu(..., log_level=4)).
Writing tabular output file results using HTML format.
/opt/oct/bin/jm_ipython.sh: line 28: 46099 Segmentation fault      (core dumped) IPOPT_HOME=${JMODELICA_HOME}/ThirdParty/IPOPT SUNDIALS_HOME=${JMODELICA_HOME}/ThirdParty/Sundials PYTHONPATH=:${JMODELICA_HOME}/Python/::$PYTHONPATH LD_LIBRARY_PATH=:${JMODELICA_HOME}/ThirdParty/IPOPT/lib/:${JMODELICA_HOME}/ThirdParty/Sundials/lib:${JMODELICA_HOME}/ThirdParty/CasADi/lib:$LD_LIBRARY_PATH SEPARATE_PROCESS_JVM=${JAVA_HOME} ipython "$@"

If I change it to

  bui->SpawnFormatError("fixme 3: Got to here %s.", modelicaName);
  getVariables(bui, modelicaName, ptrSpaObj->parameters);

so that the simulation is stopped before E+ makes any warm up, the program terminates with no seg fault.

It appears that once E+ did the warm-up (and may or may not encounter an error), then it segfaults if it is terminated immediately after the warm up. Can you reproduce this on your end with a test that calls fmi2GetReal once and then terminates the simulation?

Minimum demo for calling the OpenModelica compiler from a C/C++ program

Hello Spawn developers, regarding your question in OM, Invoke OpenModelica Compiler from a C/C++ program #10802

https://github.com/NREL/Spawn/blob/3c40cadf53709e92688f1de922b687451be21898/open_modelica/test/test_compiler.cpp

I tried to use the minimal demo you provided, but it seems to have a lot of problems, such as not found "catch2/catch.hpp", "fmt/format.h", "lohmann/json.hpp" ,and so on,I am recently studying OM same as you, can you provide some help?

embedded filesystem limitation

It appears that some special characters cause trouble. I think this is addressed for OpenStudio's embedded filesystem so it might be worth a look there.

|| /bin/sh: 1: Syntax error: "(" unexpected
make[2]: *** [cli/CMakeFiles/spawn.dir/build.make|5075| cli/embedded_files/JModelica/ThirdParty/MSL/Modelica/Resources/Images/Magnetic/QuasiStatic/FundamentalWave/Phi(ref)=Phi,re+jPhi,im_png.cxx] Error 2

In order to reproduce this, just build the "compiler_hook" branch with the MSL lines uncommented. https://github.com/NREL/Spawn/blob/compiler_hook/cli/CMakeLists.txt#L154

Add compiler tests requiring stdlib

The difficulty here will be with the llvm-msvc version. Where do we get an stdlib from.

@kbenne can you add an example file that needs to be compiled so we can verify that stdlib needs?

Setup a global default spdlog logger

The default spdlog logger uses spdlog's built in registry to store the default logger. The registry's singleton implementation uses a local static variable that causes the default logger to be non unique. https://github.com/gabime/spdlog/blob/v1.x/include/spdlog/details/registry-inl.h#L287

This has negative impliations for Spawn which uses the default logger. We would like to be able to set the log level one time at the initialization of the spawn program such as here https://github.com/NREL/Spawn/blob/compiler/cli/main.cpp#L46.

The problem is that the different compiled units of Spawn have their on log registry, so the log settings established in main do not apply to other contexts. The result is we have to set log settins for each log instance such as here https://github.com/NREL/Spawn/blob/compiler/optimica/optimica.cpp#L20.

The purpose of this issue is to design some type of common log instance that applies across compiled units.

Wrong attributes for parameters in modelDescription.xml file

Parameter values that are computed by EnergyPlus appear in the modelDescription.xml file as

<ScalarVariable name="LIVING ZONE_AFlo" valueReference="2" description="Floor area"
  causality="local" variability="constant" initial="exact">
  <Real quantity="Area" relativeQuantity="false" start="12.0" unit="m2" />
</ScalarVariable>

This is the wrong causality because the standard says:

"local" : Local variable that is calculated from other variables or is a continuous-time state (see section 2.2.8). It is not allowed to use the variable value in another model or slave.

It should be causality = "calculatedParameter" and variability = "fixed" and initial = "calculated", and the start attribute needs to be removed.

Spawn v5.0 runtime issue

Dear spawn
Screenshot from 2023-12-26 18-43-55
,

I have successfully compiled Spawn v5.0 from https://github.com/NREL/Spawn/tree/v0.5.0. However, when attempting to generate an FMU, I encounter a SIGSEGV (core dumped) error. I have attached the trace file. My initial suspicion is that the Modelica Standard Library might not be loading, and some variables used by MBL may not be initialized yet. I'm uncertain if I'm investigating the right direction. Your insights would be greatly appreciated.

Best regards,
Karan

Surface temperature initializes with 0 Kelvin, causing E+ to return with error

EnergyPlus runs its initialization during fmi2SetupExperiment, but at this time, there is no means yet to set the surface temperature, see chart below.

image

For this input, E+ seems to use 0 Kelvin and then errors with Error from EnergyPlus: Temperature (low) out of bounds [-273.15] for zone="LIVING ZONE", for surface="LIVING:FLOOR"

Below is the output from Buildings.ThermalZones.EnergyPlus.Validation.ZoneSurface.OneZoneControlledFloorTemperature (branch issue2358_spawn_surface).

0.000 OneZoneControlledFloorTemperature.building: Calling fmi2_import_setup_experiment: Setting up experiment building at 0x5567d8ed5ae0 with startTime = 0.000000.
0.000 OneZoneControlledFloorTemperature.building: Warning from EnergyPlus: ManageSizing: For a zone sizing run, there must be at least 1 Sizing:Zone input object. SimulationControl Zone Sizing option ignored.
0.000 OneZoneControlledFloorTemperature.building: Warning from EnergyPlus: ManageSizing: For a plant sizing run, there must be at least 1 Sizing:Plant object input. SimulationControl Plant Sizing option ignored.
0.000 OneZoneControlledFloorTemperature.building: Warning from EnergyPlus: ProcessScheduleInput: Schedule:Constant="SPAWN-RADIANTGAINS-SCHEDULE", Blank Schedule Type Limits Name input -- will not be validated.
0.000 OneZoneControlledFloorTemperature.building: Info from EnergyPlus: Testing Individual Branch Integrity
0.000 OneZoneControlledFloorTemperature.building: Info from EnergyPlus: All Branches passed integrity testing
0.000 OneZoneControlledFloorTemperature.building: Info from EnergyPlus: Testing Individual Supply Air Path Integrity
0.000 OneZoneControlledFloorTemperature.building: Info from EnergyPlus: All Supply Air Paths passed integrity testing
0.000 OneZoneControlledFloorTemperature.building: Info from EnergyPlus: Testing Individual Return Air Path Integrity
0.000 OneZoneControlledFloorTemperature.building: Info from EnergyPlus: All Return Air Paths passed integrity testing
0.000 OneZoneControlledFloorTemperature.building: Info from EnergyPlus: No node connection errors were found.
0.000 OneZoneControlledFloorTemperature.building: Info from EnergyPlus: Beginning Simulation
0.000 OneZoneControlledFloorTemperature.building: Error from EnergyPlus: Temperature (low) out of bounds [-273.15] for zone="LIVING ZONE", for surface="LIVING:FLOOR"
0.000 OneZoneControlledFloorTemperature.building: Error from EnergyPlus:  Environment=SPAWN-RUNPERIOD, at Simulation time=01/01 00:00 - 00:00
0.000 OneZoneControlledFloorTemperature.building: Error from EnergyPlus: Zone="LIVING ZONE", Diagnostic Details:
0.000 OneZoneControlledFloorTemperature.building: Error from EnergyPlus: ...Internal Heat Gain [8.072] W/m2
0.000 OneZoneControlledFloorTemperature.building: Error from EnergyPlus: ...Infiltration/Ventilation [0.000] m3/s
0.000 OneZoneControlledFloorTemperature.building: Error from EnergyPlus: ...Mixing/Cross Mixing [0.000] m3/s
0.000 OneZoneControlledFloorTemperature.building: Error from EnergyPlus: ...Zone is not part of HVAC controlled system.
0.000 OneZoneControlledFloorTemperature.building: Error from EnergyPlus: Temperature (low) out of bounds [-273.15] for zone="LIVING ZONE", for surface="LIVING:FLOOR"
0.000 OneZoneControlledFloorTemperature.building: Error from EnergyPlus:  Environment=SPAWN-RUNPERIOD, at Simulation time=01/01 00:00 - 00:00
0.000 OneZoneControlledFloorTemperature.building: Fatal from EnergyPlus: Program terminates due to preceding condition.
0.000 OneZoneControlledFloorTemperature.building: Info from EnergyPlus: ===== Recurring Error Summary =====
0.000 OneZoneControlledFloorTemperature.building: Info from EnergyPlus: The following recurring error messages occurred.
0.000 OneZoneControlledFloorTemperature.building: Info from EnergyPlus:  ** Severe  ** Temperature (low) out of bounds for zone=LIVING ZONE for surface=LIVING:FLOOR
0.000 OneZoneControlledFloorTemperature.building: Info from EnergyPlus:  **   ~~~   **   This error occurred 1 total times;
0.000 OneZoneControlledFloorTemperature.building: Info from EnergyPlus:  **   ~~~   **   during Warmup 0 times;
0.000 OneZoneControlledFloorTemperature.building: Info from EnergyPlus:  **   ~~~   **   during Sizing 0 times.
0.000 OneZoneControlledFloorTemperature.building: Error from EnergyPlus:  ** Severe  ** Temperature (low) out of bounds for zone=LIVING ZONE for surface=LIVING:FLOOR
0.000 OneZoneControlledFloorTemperature.building: Error from EnergyPlus: 
0.000 OneZoneControlledFloorTemperature.building: Info from EnergyPlus:  **   ~~~   **   Max=-273.149994 C  Min=-273.149994 C
0.000 OneZoneControlledFloorTemperature.building: Info from EnergyPlus: ===== Final Error Summary =====
0.000 OneZoneControlledFloorTemperature.building: Info from EnergyPlus: The following error categories occurred.  Consider correcting or noting.
0.000 OneZoneControlledFloorTemperature.building: Info from EnergyPlus: Temperature (low) out of bounds
0.000 OneZoneControlledFloorTemperature.building: Info from EnergyPlus: ..A temperature out of bounds problem can be caused by several things. The user should check:
0.000 OneZoneControlledFloorTemperature.building: Info from EnergyPlus: ..1) the weather environment (including the horizontal IR from sky)
0.000 OneZoneControlledFloorTemperature.building: Info from EnergyPlus: ..2) the level of interal gains with respect to the zone
0.000 OneZoneControlledFloorTemperature.building: Info from EnergyPlus: ..3) the thermal properties of their materials.  And other things.
0.000 OneZoneControlledFloorTemperature.building: Info from EnergyPlus: ..A common cause is a building with no or little thermal mass - all materials with Material:NoMass definitions.
0.000 OneZoneControlledFloorTemperature.building: Info from EnergyPlus: EnergyPlus Warmup Error Summary. During Warmup: 0 Warning; 0 Severe Errors.
0.000 OneZoneControlledFloorTemperature.building: Info from EnergyPlus: EnergyPlus Sizing Error Summary. During Sizing: 2 Warning; 0 Severe Errors.
0.000 OneZoneControlledFloorTemperature.building: Info from EnergyPlus: EnergyPlus Terminated--Fatal Error Detected. 3 Warning; 2 Severe Errors; Elapsed Time=00hr 00min  0.42sec
0.000 OneZoneControlledFloorTemperature.building: Returned from setting up experiment with status Error.

As a work-around, this type of variable should be set to 20 degC inside E+. In future revisions, we could implement the execution sequence according to the FMI specification.

@kbenne : Can you please make a new built with this corrected. This prevents further testing on my end.

Schedule update lags

When schedule values are actuated from Spawn, the new values are not reflected until EnergyPlus iterates. The solution is to call the schedule update function every time Spawn exchanges data.

Job Failed #571837550

Job #571837550 failed for b097485:

This test fails because the unzipper doesn't see the epfmi.dll. The thing is that I checked and it sure appears to be there with that name, so I'm not immediately sure what the issue is. @lefticus Can you take a look when you are next working in this area?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.