1 | within ;
|
---|
2 | package Test
|
---|
3 | import SI = Modelica.SIunits;
|
---|
4 |
|
---|
5 | model System
|
---|
6 | replaceable model fluid = Fluids.StandardOil constrainedby Fluids.BaseFluid
|
---|
7 | "Fluid model" annotation (
|
---|
8 | choicesAllMatching = true);
|
---|
9 | fluid Oil;
|
---|
10 | end System;
|
---|
11 |
|
---|
12 | model M
|
---|
13 | outer System system;
|
---|
14 | final parameter SI.Density rhoOil = system.Oil.density(300) "oil density";
|
---|
15 |
|
---|
16 | annotation (Icon(coordinateSystem(preserveAspectRatio=false)), Diagram(
|
---|
17 | coordinateSystem(preserveAspectRatio=false)));
|
---|
18 | end M;
|
---|
19 |
|
---|
20 | model S
|
---|
21 | inner System system(redeclare model fluid =
|
---|
22 | Fluids.RealOil);
|
---|
23 | M m;
|
---|
24 | annotation (Icon(coordinateSystem(preserveAspectRatio=false)), Diagram(
|
---|
25 | coordinateSystem(preserveAspectRatio=false)));
|
---|
26 | end S;
|
---|
27 |
|
---|
28 | package Fluids
|
---|
29 | partial model BaseFluid
|
---|
30 | extends Modelica.Icons.MaterialProperty;
|
---|
31 | partial function baseDensity "Base function for density calculation"
|
---|
32 | extends Modelica.Icons.Function;
|
---|
33 | input SI.Temperature T "fluid temperature";
|
---|
34 | output SI.Density rho "fluid density";
|
---|
35 | end baseDensity;
|
---|
36 | end BaseFluid;
|
---|
37 |
|
---|
38 | model StandardOil
|
---|
39 | extends Test.Fluids.BaseFluid;
|
---|
40 |
|
---|
41 | function density "function for density calculation"
|
---|
42 | extends Test.Fluids.BaseFluid.baseDensity;
|
---|
43 | algorithm
|
---|
44 | rho := 890;
|
---|
45 | end density;
|
---|
46 | end StandardOil;
|
---|
47 |
|
---|
48 | model RealOil
|
---|
49 | extends Test.Fluids.BaseFluid;
|
---|
50 |
|
---|
51 | function density "function for density calculation"
|
---|
52 | extends Test.Fluids.BaseFluid.baseDensity;
|
---|
53 | protected
|
---|
54 | final constant SI.Temperature T_vect[:] = {273.15+40, 273.15+100};
|
---|
55 | final constant SI.Density rho_vect[:] = {880, 885};
|
---|
56 | algorithm
|
---|
57 | rho := Modelica.Math.Vectors.interpolate(T_vect, rho_vect, T);
|
---|
58 | end density;
|
---|
59 |
|
---|
60 | end RealOil;
|
---|
61 | end Fluids;
|
---|
62 |
|
---|
63 | annotation (Icon(coordinateSystem(preserveAspectRatio=false)), Diagram(
|
---|
64 | coordinateSystem(preserveAspectRatio=false)),
|
---|
65 | uses(Modelica(version="3.2.2")));
|
---|
66 | end Test;
|
---|