-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated to handle indirect parameter file reading
- Loading branch information
Dag Brück
committed
Jul 1, 2024
1 parent
edf115f
commit 5b873d1
Showing
7 changed files
with
26 additions
and
13 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
examples/MasterParameter/MasterParameter/InitializeArray.mo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
within MasterParameter; | ||
function InitializeArray "Reads initial values for vector parameter" | ||
input String filename "File to read parameters from"; | ||
output Real v[:] "Parameter vector from file"; | ||
protected | ||
Integer n=Modelica.Utilities.Streams.countLines(filename); | ||
String data[:]=Modelica.Utilities.Streams.readFile(filename); | ||
algorithm | ||
v := fill(0.0, n); // Initialization needed to get the right size | ||
for i in 1:n loop | ||
v[i] := Modelica.Utilities.Strings.scanReal(data[i]); | ||
end for; | ||
end InitializeArray; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
within MasterParameter; | ||
record ParSet "Simple parameter set with array data" | ||
// Old fixed-sized array: Real J[4] = { 1.0, 1.0, 1.0, 1.0}; | ||
Real J[:] "Component index and inertia" annotation(__Dymola_UnknownArray=true); | ||
String datafile "Name of real parameter file"; | ||
Real J[:] "Component inertia" annotation(__Dymola_UnknownArray=true); | ||
end ParSet; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
ParSet | ||
InitializeArray | ||
InitializeParameters | ||
Test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
parmeterfile.txt | ||
parameterfile.txt |