Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
64 additions
and
12 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// name: clockedSolverTest | ||
// keywords: synchronous clocked equations, continuous equations | ||
// status: correct | ||
// teardown_command: rm -f *SolverMethod* | ||
|
||
setCommandLineOptions("+simCodeTarget=Cpp"); | ||
|
||
loadString(" | ||
model SolverMethod \"Continuous PI controller in a clocked partition; | ||
see Modelica 3.3 spec, section 16.8.3 Associating a Solver to a Partition\" | ||
parameter Real Ti = 200/1000, k = 2; | ||
parameter Real ref = 1; | ||
Real x(start = 0, fixed = true); | ||
Real xd(start = 0); | ||
Real vd, e, u; | ||
equation | ||
// controller | ||
vd = sample(x, Clock(Clock(50,1000), solverMethod = \"ImplicitEuler\")); | ||
e = ref-vd; | ||
der(xd) = e/Ti; | ||
u = k*(e + xd); | ||
// physical model | ||
0.2*der(x) = hold(u); | ||
end SolverMethod; | ||
"); | ||
getErrorString(); | ||
|
||
simulate(SolverMethod); | ||
val(x, 0.0); | ||
val(x, 0.3); | ||
val(x, 1.0); | ||
val(xd, 0.0); | ||
val(xd, 0.3); | ||
val(xd, 1.0); | ||
getErrorString(); | ||
|
||
// Result: | ||
// true | ||
// true | ||
// "" | ||
// record SimulationResult | ||
// resultFile = "SolverMethod_res.mat", | ||
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'SolverMethod', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''", | ||
// messages = "" | ||
// end SimulationResult; | ||
// 0.0 | ||
// 1.214168548583985 | ||
// 0.998146335431809 | ||
// 0.25 | ||
// 0.186729431152344 | ||
// -0.0010129555314779 | ||
// "" | ||
// endResult |