Skip to content

Choose from different parameter records containing different approximation functions #3841

@AHaumer

Description

@AHaumer

Is it legal Modelica to include a function definition in a parameter record?

record Data "Material parameters"
  extends Modelica.Icons.Record;
  parameter Real x1 "Nominal point x";
  parameter Real y1 "Nominal pint y";
  parameter Real s0 "Slope beyond nominal point";
  function approx
    extends Modelica.Icons.Function;
    input Data data "Materal parameters";
    input Real x "Actual x";
    output Real y "Actual y";
  algorithm
    y:=data.y1/data.x1*min(x, data.x1) + data.s0*max(x - data.x1, 0);
  end approx;
end Data;

This would open the possibility to use different approximations for material behaviour just by choosing the material,
if the approximation functions for different materials have the same name and structure (inputs and output).

Metadata

Metadata

Assignees

No one assigned

    Labels

    discussionDiscussion issue that it not necessarily related to a concrete bug or feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions