Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Choose from different parameter records containing different approximation functions #3841

Closed
AHaumer opened this issue Jun 13, 2021 · 3 comments
Labels
discussion Discussion issue that it not necessarily related to a concrete bug or feature help wanted Extra attention is needed

Comments

@AHaumer
Copy link
Contributor

AHaumer commented Jun 13, 2021

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).

@AHaumer AHaumer added discussion Discussion issue that it not necessarily related to a concrete bug or feature help wanted Extra attention is needed labels Jun 13, 2021
@beutlich
Copy link
Member

Functions in records are used in ExternData, too. Note, that they need to be public.

@AHaumer
Copy link
Contributor Author

AHaumer commented Jun 16, 2021

Ok thanks a lot @beutlich ! I have to admit it's a bit more complicated:
I want to choose from different materials, and these are grouped by approximation method of a certain property.
The property is the same for all materials. For each group there's a base record, defining the parameters and the approximation function (which uses the parameter record!). I can't get a legal solution, - well hard to explain, easier to look at: I've enclosed what I have so far. Any hints welcome!
TestLib.zip

@AHaumer
Copy link
Contributor Author

AHaumer commented Jun 17, 2021

Analyzing the problem:

  • Common base parameter record to be able to choose from different parameters sets (with different approximation function)
  • Common base approximation function to use it in the components, independent of the later chosen materia
  • Use of the parameter set as input to the approximation function
  • Approximation function included in the parameter record (tied to the parameters)
  • Collections of parameter sets, each collection witg different parameters and different approximation function

@AHaumer AHaumer changed the title Include function definition in parameter record legal? Choose from different parameter records containing different approximation functions Jun 20, 2021
@modelica modelica locked and limited conversation to collaborators Nov 8, 2021
@beutlich beutlich closed this as completed Nov 8, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
discussion Discussion issue that it not necessarily related to a concrete bug or feature help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants