3

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

Akhil Nandan
  • 315
  • 2
  • 9
neon
  • 33
  • 4

2 Answers2

6

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;
Rene Just Nielsen
  • 3,023
  • 12
  • 15
  • 1
    Another exception regarding changing existing code is 'selective model extension' that has recently been added to the Modelica specification. However, that only allows you to remove components and connections - not other equations. – Hans Olsson Feb 02 '23 at 10:04
5

The usage of extends suggests one wants to inherit all the behaviours of the extended class. You can change those behaviours unless they are redeclarable. The best is to create a new class by duplicating the base model and then change the behaviours as you want. Hope this works!

Duplicate a class in OpenModelica

Akhil Nandan
  • 315
  • 2
  • 9