2
votes

I am required to read time-series data (csv for example) in Modelica, specifically using the open modelica compiler (omc). I did some internet search and found a ncReader library on the net. It works on dymola but not with the open modelica compiler. My test code is like this:

  der(x) = t;  
  t = NcDataReader2.ncEasyGet1D("datafile.nc", "temperature", time);  
  der(y) = q;  
  q = NcDataReader2.ncEasyGet1D("datafile.nc", "flow", time); 

When I try to run it on open modelica, I get the following error:

Translation 09:21:41 0:0-0:0 Error building simulator. Build log: gcc -falign-functions -msse2 -mfpmath=sse -I"C:/OpenModelica1.9.0//include/omc" -I. -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME -c -o TimeSeries.NcTest.o TimeSeries.NcTest.c TimeSeries.NcTest.c:19:28: error: ncDataReaderEA.h: No such file or directory mingw32-make: *** [TimeSeries.NcTest.o] Error 1

I think the reason it works on dymola is because dymola uses a C compiler and maybe compiling the c file of the library on the fly. Unfortunately, I have to use open modelica.

Can anyone help if this error can be fixed for using with the open modelica compiler OR if there is any other alternative to read-time series data file in modelica (open modelica compiler)?

Thanks in advance

1
There are currently two versions of the netCDF reader, the original version by Jörg Rädler on bitbucket and the fork by Thomas Beutlich on github, which one do you use? Please add the info to your question (e.g. as a link).matth
There exists at least one alternative, a HDF5 Reader by Modelon: bitbucket.org/modelon/simdevtoolsmatth
Where did you put the library .c and .h files such as ncDataReaderEA.h? You need to give that information to the OpenModelica compiler otherwise it won't find them. You could put them inside C:/OpenModelica1.9.0//include/omc or the current directory where your model is. Either this or set an environment variable MODELICAUSERCFLAGS=-Idirectory/with/h/filesAdrian Pop
.c and .h files are in the same directory as the .mo file. I haven't tried putting them into omc directory but in my vies doing so doesn't make the .mo file portable. I wish there is an easier way of doing it. I wondered why such important feature didn't get that much attention.codelearner
it doesn't work even after adding the .h file under omc. The error persists with the "missing" ncDataReaderEA.hcodelearner

1 Answers

0
votes

I am late by two years, but here is a solution. Use the block Modelica/Blocks/Sources/CombiTimeTable
Your txt file should follow this format

#1
double tableName(rows, columns)

0   0.1   32
1   0.2   35
2   0.3   38

where first column should be time in ascending order and other columns are the respective data.