StephenSmith25 / PythonFMU3

A lightweight framework that enables the packaging of Python3.x code as co-simulation FMUs following version 3.0
MIT License
7 stars 2 forks source link

Model description does not end up in the FMU #7

Closed steve-biggs-fox closed 2 months ago

steve-biggs-fox commented 2 months ago

Documentation shows that the model description should be specified like this:

class PythonSlave(Fmi3Slave):

    author = "John Doe"
    description = "A simple description"
    ...

However, if I then run fmpy.dump(...) on the resultant FMU, it displays the following:

Model Info

  FMI Version        3.0
  FMI Type           Co-Simulation
  Model Name         PythonSlave
  Description        None
  ...

By contrast, if I run fmpy.dump(...) on an FMU generated by another program, then I get, for example:

Model Info

  FMI Version        2.0
  FMI Type           Co-Simulation
  Model Name         160424_V9LCSUT
  Description        Simcenter Flomaster network with FMI for co-simulation interface
  ...

i.e. the problem is not with fmpy.dump(...).

steve-biggs-fox commented 2 months ago

I got the description to work like this:

class PythonSlave(Fmi3Slave):

    def __init__(self, **kwargs):
        super().__init__(**kwargs)

        self.description = (
            "A simple description"
        )

        ....

i.e. the description needs to be an instance variable (self.description within the init method), not a class variable (just description within the class but outside any methods).

So, it seems this is a problem with the documentation rather than the code.

StephenSmith25 commented 2 months ago

I'll have to look at this as I have not come across it, thanks for raising it! (And finding the solution)

StephenSmith25 commented 2 months ago

Fixed. Indicated that the description should appear in __init__ rather than as a class attribute.