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

Problem with compiling FMU using BuildingsLibrary ReaderTMY3 in JModelica

asked 2019-11-21 16:43:37 -0600

amyeallen1's avatar

I'm trying to compile and simulate a Modelica model that I've tested in Dymola using JModelica. The model uses the ReaderTMY3 component from the Modelica Buildings Library to read in weather data. The model simulates as expected in Dymola, but when I try to compile to an FMU in JModelica, I get the warning or error message below regarding the ReaderTMY3 finding an empty string for the latitude and time zone.

The latitude and time zone are present in the header of the .mos weather file, in the expected positions. Here is the relevant line of the .mos weather file (#LOCATION,Denver Centennial Golden Nr,CO,USA,TMY3,724666,39.74,-105.18,-7.0,1829.0). (I also tried omitting the spaces in the location name, and got the same messages.)

Does anyone have advice on how to resolve this? Thanks very much.

function Buildings.BoundaryConditions.WeatherData.BaseClasses.getLatitudeTMY3 input String filNam; output Real lat; Integer nexInd; String element; algorithm element := Buildings.BoundaryConditions.WeatherData.BaseClasses.getHeaderElementTMY3(filNam, "#LOCATION", "longitude", 7); (nexInd, lat) := Modelica.Utilities.Strings.Advanced.scanReal(element, 1, false); assert(nexInd > 1, "Error when converting the latitude '" + element + "' from a String to a Real."); lat := lat * 3.141592653589793 / 180; assert(abs(lat) <= 3.141592653589793 + 1.0E-15, "Wrong value for latitude. Received lat = " + String(lat) + " (= " + String(lat * 180 / 3.141592653589793) + " degrees)."); return; end Buildings.BoundaryConditions.WeatherData.BaseClasses.getLatitudeTMY3;

function Buildings.BoundaryConditions.WeatherData.BaseClasses.getTimeZoneTMY3 input String filNam; output Real timZon; Integer nexInd; String element; algorithm element := Buildings.BoundaryConditions.WeatherData.BaseClasses.getHeaderElementTMY3(filNam, "#LOCATION", "longitude", 9); (nexInd, timZon) := Modelica.Utilities.Strings.Advanced.scanReal(element, 1, false); assert(nexInd > 1, "Error when converting the time zone '" + element + "' from a String to a Real."); timZon := timZon * 3600; assert(abs(timZon) < 24 * 3600, "Wrong value for time zone. Received timZon = " + String(timZon) + " (= " + String(timZon / 3600) + " hours)."); return; end Buildings.BoundaryConditions.WeatherData.BaseClasses.getTimeZoneTMY3;

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2019-11-21 23:29:58 -0600

Amy,

Does the simple unit test Buildings.BoundaryConditions.WeatherData.BaseClasses.Examples.GetHeaderElement work for you with the weather file used in the example of the Buildings Library, and if so, does it work with your weather file? Are you using the JModelica docker image from https://github.com/lbl-srg/docker-ubu... or another version? Loading files was fixed in JModelica about half a year ago, so if you use an old version, you may need to update.

The message you show looks like JModelica is just writing the function body to an output, but this is not an error message. Error messages should be in *_log.txt.

edit flag offensive delete link more

Comments

Hi Michael, Thanks for the quick response, and for your advice. The weather file I was using did not pass the unit test, but the one in the example folder did. When I tried to compile the FMU with the model adjusted to use the example weather file for Chicago, I got the same messages regarding getLatitude and getTimeZone, but there were no error messages regarding that in the log file. I will try re-generating the .mos weather file for the other location.

I'm using JModelica 2.4, and not using Docker for the compilation or simulation. Would 2.4 have the file loading problem fixed?

amyeallen1's avatar amyeallen1  ( 2019-11-22 15:14:18 -0600 )edit

Hi Amy JModelica 2.4 is pretty old, the current version is 2.10. I suggest you update or use the docker image which we frequently test with the Building Library and update. Then, I suggest you make sure Buildings.BoundaryConditions.WeatherData.BaseClasses.Examples.GetHeaderElement works as is and that it also works with your weather file before moving to a larger model.

Michael Wetter's avatar Michael Wetter  ( 2019-11-22 15:41:23 -0600 )edit

Hi Michael, okay, thanks, that makes sense. I will update to 2.10 and figure out the problems with the weather file.

amyeallen1's avatar amyeallen1  ( 2019-11-22 16:27:18 -0600 )edit

Your Answer

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

Add Answer

Training Workshops

Careers

Question Tools

1 follower

Stats

Asked: 2019-11-21 16:43:37 -0600

Seen: 359 times

Last updated: Nov 21 '19