Skip to content

Results from *.get() method differ from simulation result object #178

@LukasKoenemann

Description

@LukasKoenemann

Hi,
I'm using pyfmi to simulate my modelica models in python. First I'm calling the simulation in my declared class (result = selfmodel.simulate()). Later on I fetch my variables via the .get() method (value = model.get(variable)). Now I'm wondering, that the values for the get() sometimes differ from the values of the result- object:
code:

            result = self.model.simulate(
                input=input_object,
                start_time=start_time,
                final_time=stop_time,
                options=opts,
            )
            for variable in ['TAC', 'electrical_storage[1].F']:
                print(f'\t - result[{variable}]:', result[variable][-1])
                print(f'\t - model.final({variable})', result.final(variable))
                print(f'\t - get_variable({variable}):', self.get_variable(variable))

output:

         - result[TAC]: 123360.32496377944
         - model.final(TAC) 123360.32496377944
         - get_variable(TAC): 123857.68462234597
         - result[electrical_storage[1].F]: 0.9997065955338098
         - model.final(electrical_storage[1].F) 0.9997065955338098
         - get_variable(electrical_storage[1].F): 0.9997065955338098

Do you know where the difference come from? And which value is the "true" value?

  • this is how my get_variable() method looks like:

    def get_variable(self, name) -> float:
        return self.model.get(name).item()

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions