1

I have a string vector with the names of some substances vec = {"H2","O2"}, and I would like to use these strings to access a record in a package such that

Modelica.Media.IdealGases.Common.SingleGasesData.'vec[1]'

returns the data of H2.

Is this possible in Modelica, or do I have to do it manually?

Johannes Veje
  • 83
  • 1
  • 1
  • 5

1 Answers1

0

I ended up doing it manually:

import d = Modelica.Media.IdealGases.Common.SingleGasesData;
constant Modelica.Media.IdealGases.Common.DataRecord data[Species]={d.H2,d.O2};

It might be slow and requires some index tracking, but for small sizes it is doable.

Johannes Veje
  • 83
  • 1
  • 1
  • 5