Search code examples
modelicaopenmodelica

How to inherit a standard Fluid component and override and replace some equations of the base model?


I want to customize a standard Fluid Library component in Modelica using OpenModelica. 

I want to create a customized version of a new Pump where several equations will be changed.

I inherited Fluid.Machines.BaseClasses.PartialPump as a base model by "extends" keyword. When I tried to change and redefine an equation, it gave an overdetermined system error.  I put redeclare or redifine in front of the equation, and it still gives an error.

What is the best way to create a customised component model without copying everything into a new model? 

Thanks


Solution

  • Unfortunately, you cannot change existing code* — you can only add new code.

    In your case, you will have to make a copy of Fluid.Machines.BaseClasses.PartialPump and modify the equation in question. However, you don't necessarily need to copy its base class (Modelica.Fluid.Interfaces.PartialTwoPort).

    The PartialPump model is quite versatile. If you need different pump curves (pressure, efficiency or power) you can write additional functions based on the base classes in Fluid.Machines.BaseClasses.PumpCharacteristics.

    *) One exception to my initial statement is the inheritance of graphical annotations: if you extend a model and add the annotation primitivesVisible=false the graphical annotations (icon) will not be inherited, for example:

    model myModel
      extends baseModel annotation(IconMap(primitivesVisible=false));
    
      <new icon annotations>
    end myModel;