From d75524b9eb3025a6609eeeb0619b6cb94206cf16 Mon Sep 17 00:00:00 2001 From: AnHeuermann <38031952+AnHeuermann@users.noreply.github.com> Date: Mon, 16 Mar 2026 10:57:33 +0100 Subject: [PATCH] Remove Base Modelica MTK test --- .CI/Jenkinsfile | 29 +-- .github/workflows/test.yml | 1 - .github/workflows/test_julia.yml | 109 ----------- README.md | 14 -- TestBaseModelica/.gitignore | 2 - TestBaseModelica/Project.toml | 27 --- TestBaseModelica/README.md | 57 ------ .../examples/CauerLowPassAnalog.bmo | 177 ----------------- .../examples/CauerLowPassAnalogSine.bmo | 182 ------------------ .../CauerLowPassAnalogSineNoAssert.bmo | 180 ----------------- TestBaseModelica/examples/ChuaCircuit.bmo | 113 ----------- .../examples/ChuaCircuitNoAssert.bmo | 113 ----------- TestBaseModelica/examples/Experiment.bmo | 12 -- TestBaseModelica/examples/FirstOrder.bmo | 12 -- TestBaseModelica/examples/IfEquation.bmo | 14 -- TestBaseModelica/examples/MinimalValid.bmo | 5 - TestBaseModelica/examples/Modifier.bmo | 9 - .../examples/NegativeVariable.bmo | 8 - .../examples/NewtonCoolingBase.bmo | 16 -- .../examples/ParameterWithModifiers.bmo | 11 -- TestBaseModelica/examples/README.md | 6 - TestBaseModelica/precompile_skript.jl | 34 ---- TestBaseModelica/src/TestBaseModelica.jl | 52 ----- TestBaseModelica/src/settings.jl | 63 ------ TestBaseModelica/test/runtests.jl | 4 - TestBaseModelica/test/test_parse.jl | 41 ---- basemodelica.py | 72 ------- requirements.txt | 1 - test.py | 21 -- testmodel.py | 53 ----- 30 files changed, 1 insertion(+), 1437 deletions(-) delete mode 100644 .github/workflows/test_julia.yml delete mode 100644 TestBaseModelica/.gitignore delete mode 100644 TestBaseModelica/Project.toml delete mode 100644 TestBaseModelica/README.md delete mode 100644 TestBaseModelica/examples/CauerLowPassAnalog.bmo delete mode 100644 TestBaseModelica/examples/CauerLowPassAnalogSine.bmo delete mode 100644 TestBaseModelica/examples/CauerLowPassAnalogSineNoAssert.bmo delete mode 100644 TestBaseModelica/examples/ChuaCircuit.bmo delete mode 100644 TestBaseModelica/examples/ChuaCircuitNoAssert.bmo delete mode 100644 TestBaseModelica/examples/Experiment.bmo delete mode 100644 TestBaseModelica/examples/FirstOrder.bmo delete mode 100644 TestBaseModelica/examples/IfEquation.bmo delete mode 100644 TestBaseModelica/examples/MinimalValid.bmo delete mode 100644 TestBaseModelica/examples/Modifier.bmo delete mode 100644 TestBaseModelica/examples/NegativeVariable.bmo delete mode 100644 TestBaseModelica/examples/NewtonCoolingBase.bmo delete mode 100644 TestBaseModelica/examples/ParameterWithModifiers.bmo delete mode 100644 TestBaseModelica/examples/README.md delete mode 100644 TestBaseModelica/precompile_skript.jl delete mode 100644 TestBaseModelica/src/TestBaseModelica.jl delete mode 100644 TestBaseModelica/src/settings.jl delete mode 100644 TestBaseModelica/test/runtests.jl delete mode 100644 TestBaseModelica/test/test_parse.jl delete mode 100644 basemodelica.py diff --git a/.CI/Jenkinsfile b/.CI/Jenkinsfile index 0db2bcd..5f68624 100644 --- a/.CI/Jenkinsfile +++ b/.CI/Jenkinsfile @@ -30,8 +30,6 @@ pipeline { booleanParam(name: 'report_ryzen_5950x_1', defaultValue: false, description: 'Generate a report for ryzen-5950x-1 without running the tests') booleanParam(name: 'report_ryzen_5950x_2', defaultValue: false, description: 'Generate a report for ryzen-5950x-2 without running the tests') - booleanParam(name: 'basemodelica_jl_master', defaultValue: false, description: 'OpenModelica master branch with BaseModelica export and BaseModelica.jl import (ryzen-5950x-1)') - booleanParam(name: 'conversion_script', defaultValue: false, description: 'master branch with conversion script from MSL 3 to 4 (ryzen-5950x-1). This is an experimental job that does not run on a fixed schedule.') booleanParam(name: 'cvode', defaultValue: false, description: 'master branch, with -d=newInst and -s cvode (ryzen-5950x-2). This is an experimental job that does not run on a fixed schedule.') booleanParam(name: 'gbode', defaultValue: false, description: 'master branch, with -d=newInst and -s gbode (ryzen-5950x-2). This is an experimental job that does not run on a fixed schedule.') @@ -279,23 +277,6 @@ pipeline { } } - stage('master BaseModelica.jl import') { - agent { - node { - label 'ryzen-5950x-1' - customWorkspace 'ws/OpenModelicaLibraryTestingWork' - } - } - options { skipDefaultCheckout() } - when { - beforeAgent true - expression { params.basemodelica_jl_master } - } - steps { - runRegressiontest('master', 'basemodelica_jl_master', '', '', 'ripper1', 'LibraryTestingRipper1DB', false, '', false, false, 0, 'configs/basemodelica.json') - } - } - stage('newInst-daeMode') { agent { node { @@ -716,7 +697,6 @@ def runRegressiontest(branch, name, extraFlags, omsHash, dbPrefix, sshConfig, om fi ''' FMI_TESTING_FLAG="" - JULIA_TESTTING_FLAG="" if (!name.contains('fmpy') && omsHash) { sh """ if ! test -d OMSimulator; then @@ -764,13 +744,6 @@ def runRegressiontest(branch, name, extraFlags, omsHash, dbPrefix, sshConfig, om FMI_TESTING_FLAG="--fmi=true --fmisimulator='python3 -m fmpy' --default=ulimitExe=50" } - if (name.contains('basemodelica_jl')) { - sh """ - julia --project=TestBaseModelica -e 'import Pkg; Pkg.build(verbose=true); Pkg.precompile()' - """ - JULIA_TESTTING_FLAG="--basemodelica-mtk-import --no-julia-sys-image" - } - OMCPATH = "${omcompiler ? '../' : './'}OMCompiler" sh ''' @@ -920,7 +893,7 @@ def runRegressiontest(branch, name, extraFlags, omsHash, dbPrefix, sshConfig, om cd OpenModelicaLibraryTesting # Force /usr/bin/omc as being used for generating the mos-files. Ensures consistent behavior among all tested OMC versions - stdbuf -oL -eL time ./test.py --ompython_omhome=/usr ${FMI_TESTING_FLAG} ${JULIA_TESTTING_FLAG} --extraflags='${extraFlags}' --extrasimflags='${extrasimflags}' --branch="${name}" --output="libraries.openmodelica.org:/var/www/libraries.openmodelica.org/branches/${name}/" --libraries='${libraryPath}/.openmodelica/libraries/' --jobs=${jobs} ${libs_config_file} ${params.OLDLIBS ? "configs/conf-old.json configs/conf-nonstandard.json" : ""} || (killall omc ; false) || exit 1 + stdbuf -oL -eL time ./test.py --ompython_omhome=/usr ${FMI_TESTING_FLAG} --extraflags='${extraFlags}' --extrasimflags='${extrasimflags}' --branch="${name}" --output="libraries.openmodelica.org:/var/www/libraries.openmodelica.org/branches/${name}/" --libraries='${libraryPath}/.openmodelica/libraries/' --jobs=${jobs} ${libs_config_file} ${params.OLDLIBS ? "configs/conf-old.json configs/conf-nonstandard.json" : ""} || (killall omc ; false) || exit 1 """ sh 'date' sh "rm -f OpenModelicaLibraryTesting/${dbPrefix}-sqlite3.db.tmp" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5eb8140..852e4b9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -53,7 +53,6 @@ jobs: - name: Install Python dependencies shell: bash run: | - sed -i '/^juliacall/d' requirements.txt # Remove juliacall to check if it works without pip install -r requirements.txt - name: Run library test diff --git a/.github/workflows/test_julia.yml b/.github/workflows/test_julia.yml deleted file mode 100644 index c063dc2..0000000 --- a/.github/workflows/test_julia.yml +++ /dev/null @@ -1,109 +0,0 @@ -name: Continuous Integration BaseModelica.jl - -on: - pull_request: - push: - branches: - - master - tags: ['*'] - -jobs: - unittest-testbasemodelica: - name: Unit test TestBaseModelica.jl - strategy: - matrix: - os: [ubuntu-latest] - julia-version: [1.12] - fail-fast: false - runs-on: ${{ matrix.os }} - timeout-minutes: 60 - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup Julia - uses: julia-actions/setup-julia@latest - with: - version: ${{ matrix.julia-version }} - - - name: Cache Julia - uses: julia-actions/cache@v2 - - - name: Build TestBaseModelica - uses: julia-actions/julia-buildpkg@v1 - with: - project: TestBaseModelica - - - name: Test TestBaseModelica - uses: julia-actions/julia-runtest@v1 - with: - project: TestBaseModelica - - test-mtk-import: - name: Sanity check TestBaseModelica.jl + test.py - strategy: - matrix: - os: [ubuntu-latest] - julia-version: [1.12] - omc-version: [stable] - python-version: ['3.10'] - fail-fast: false - runs-on: ${{ matrix.os }} - timeout-minutes: 60 - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup Julia - uses: julia-actions/setup-julia@latest - with: - version: ${{ matrix.julia-version }} - - - name: Cache Julia - uses: julia-actions/cache@v2 - - - name: Setup OpenModelica - uses: OpenModelica/setup-openmodelica@v1 - with: - version: ${{ matrix.omc-version }} - packages: | - 'omc' - libraries: | - 'Modelica 4.0.0' - omc-diff: true - - - name: Check if .CI/installLibraries.mos works - shell: bash - run: | - if [ "$RUNNER_OS" == "Linux" ]; then - omc .CI/installLibraries.mos - fi - - - name: Setup Python3 - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - cache: 'pip' # caching pip dependencies - - - name: Install Python dependencies - shell: bash - run: | - pip install -r requirements.txt - - - name: Run library test - shell: bash - env: - MY_SANITY_CHECK_DIRECTORY: sanityCheck - run: | - python test.py --branch="${{ matrix.omc-version }}" --basemodelica-mtk-import --no-julia-sys-image --noclean --verbose configs/sanityCheck.json - - - name: Generate HTML results - shell: bash - run: python report.py --branches="${{ matrix.omc-version }}" configs/sanityCheck.json - - - name: Zip HTML results - shell: bash - run: | - python .github/scripts/archiveResults.py "MyLibrary" "1.0.0" "${{ matrix.omc-version }}" "html/" diff --git a/README.md b/README.md index 9e2bd67..520fc80 100644 --- a/README.md +++ b/README.md @@ -229,17 +229,3 @@ export MSLREFERENCE="/some/path/to/ReferenceFiles/" ``` For the other libraries just clone the repositories to `/some/path/to/ReferenceFiles/`. - -## Examples - -### BaseModelica export and BaseModelica.jl import - -```bash -export MY_SANITY_CHECK_DIRECTORY=sanityCheck -./test.py --basemodelica-mtk-import --branch=master --noclean --verbose configs/sanityCheck.json -./report.py --branches="${{ matrix.omc-version }}" configs/sanityCheck.json -``` - -This will create a Julia system image to speedup tests. This can take a lot of -time, but will reduce the Julia startup penalty. To disable add -`--no-julia-sys-image`. diff --git a/TestBaseModelica/.gitignore b/TestBaseModelica/.gitignore deleted file mode 100644 index 0ad117c..0000000 --- a/TestBaseModelica/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -.CondaPkg/ -test/test_out/ diff --git a/TestBaseModelica/Project.toml b/TestBaseModelica/Project.toml deleted file mode 100644 index bed826b..0000000 --- a/TestBaseModelica/Project.toml +++ /dev/null @@ -1,27 +0,0 @@ -name = "TestBaseModelica" -uuid = "bba3f925-4bbc-4b14-b723-9b95a7c9c63c" -version = "0.1.0" -authors = ["AnHeuermann <38031952+AnHeuermann@users.noreply.github.com>"] - -[deps] -BaseModelica = "a17d5099-185d-4ff5-b5d3-51aa4569e56d" -CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b" -DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" -ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78" -OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed" -SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462" - -[sources] -BaseModelica = {rev = "main", url = "https://github.com/SciML/BaseModelica.jl.git"} - -[compat] -ModelingToolkit = "11" -OrdinaryDiffEq = "6" -SciMLBase = "2" - -[extras] -SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f" -Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" - -[targets] -test = ["SafeTestsets", "Test"] diff --git a/TestBaseModelica/README.md b/TestBaseModelica/README.md deleted file mode 100644 index 17184ea..0000000 --- a/TestBaseModelica/README.md +++ /dev/null @@ -1,57 +0,0 @@ -# TestBaseModelica - -Test coupling of Base Modelica export off OpenModelica and -[ModelingToolkit.jl](https://github.com/SciML/ModelingToolkit.jl). - -For a Base Modelica file exported by OpenModelica parsing with -[BaseModelica.jl](https://github.com/SciML/BaseModelica.jl) and simulating with -[OrdinaryDiffEq.jl](https://github.com/SciML/OrdinaryDiffEq.jl) is -tested. - -## Dependencies - -- Julia -- Julia packages - -## Precompilation - -To speed up the execution of the test and reduce the TTFP-overhad of Julia there are two options: - -1. Precompile this package with - [PackageCompiler.jl](https://github.com/JuliaLang/PackageCompiler.jl) and - start a new Julia session for each test. - - ```julia - julia> using PackageCompiler - (@v1.11) pkg> activate . - julia> create_sysimage(["TestBaseModelica"]; sysimage_path="TestBaseModelica.so", precompile_execution_file="precompile_skript.jl" ) - ``` - - ```bash - time julia --project=$(pwd) -e 'using TestBaseModelica; solver_settings=SolverSettings(start_time=0.0, stop_time=1.0, interval=0.02, tolerance=1e-6); test_settings=TestSettings(modelname="FirstOrder", output_directory="FirstOrder", solver_settings=solver_settings); run_test(joinpath("examples", "FirstOrder.bmo"); settings=test_settings)' - - time julia --sysimage=TestBaseModelica.so -e 'using .TestBaseModelica; solver_settings=SolverSettings(start_time=0.0, stop_time=1.0, interval=0.02, tolerance=1e-6); test_settings=TestSettings(modelname="FirstOrder", output_directory="FirstOrder", solver_settings=solver_settings); run_test(joinpath("examples", "FirstOrder.bmo"); settings=test_settings)' - ``` - -2. Keep a Julia daemon running in the background for all tests by using - [DaemonMode.jl](https://github.com/dmolina/DaemonMode.jl) - -## How to use - -```julia -using TestBaseModelica - -solver_settings = SolverSettings( - start_time = 0.0, - stop_time = 1.0, - interval = 0.02, - tolerance = 1e-6 -) - -test_settings = TestSettings( - modelname = "FirstOrder", - output_directory = "FirstOrder", - solver_settings = solver_settings) - -run_test(joinpath("examples", "FirstOrder.bmo"); settings = test_settings) -``` diff --git a/TestBaseModelica/examples/CauerLowPassAnalog.bmo b/TestBaseModelica/examples/CauerLowPassAnalog.bmo deleted file mode 100644 index 106fbbb..0000000 --- a/TestBaseModelica/examples/CauerLowPassAnalog.bmo +++ /dev/null @@ -1,177 +0,0 @@ -//! base 0.1.0 -package 'CauerLowPassAnalog' - model 'CauerLowPassAnalog' "Cauer low pass filter with analog components" - parameter Real 'l1'(unit = "H", quantity = "Inductance") = 1.304 "Filter coefficient I1"; - parameter Real 'l2'(unit = "H", quantity = "Inductance") = 0.8586 "Filter coefficient I2"; - parameter Real 'c1'(min = 0.0, unit = "F", quantity = "Capacitance") = 1.072 "Filter coefficient c1"; - parameter Real 'c2'(min = 0.0, unit = "F", quantity = "Capacitance") = 1.0 / (2.906997720064 * 'l1') "Filter coefficient c2"; - parameter Real 'c3'(min = 0.0, unit = "F", quantity = "Capacitance") = 1.682 "Filter coefficient c3"; - parameter Real 'c4'(min = 0.0, unit = "F", quantity = "Capacitance") = 1.0 / (1.392270203025 * 'l2') "Filter coefficient c4"; - parameter Real 'c5'(min = 0.0, unit = "F", quantity = "Capacitance") = 0.7262 "Filter coefficient c5"; - Real 'G.p.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'G.p.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'C1.v'(fixed = true, start = 0.0, unit = "V", quantity = "ElectricPotential") "Voltage drop of the two pins (= p.v - n.v)"; - Real 'C1.p.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'C1.p.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'C1.n.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'C1.n.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'C1.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing from pin p to pin n"; - parameter Real 'C1.C'(start = 1.0, min = 0.0, unit = "F", quantity = "Capacitance") = 'c1' "Capacitance"; - Real 'C2.v'(start = 0.0, unit = "V", quantity = "ElectricPotential") "Voltage drop of the two pins (= p.v - n.v)"; - Real 'C2.p.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'C2.p.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'C2.n.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'C2.n.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'C2.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing from pin p to pin n"; - parameter Real 'C2.C'(start = 1.0, min = 0.0, unit = "F", quantity = "Capacitance") = 'c2' "Capacitance"; - Real 'C3.v'(fixed = true, start = 0.0, unit = "V", quantity = "ElectricPotential") "Voltage drop of the two pins (= p.v - n.v)"; - Real 'C3.p.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'C3.p.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'C3.n.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'C3.n.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'C3.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing from pin p to pin n"; - parameter Real 'C3.C'(start = 1.0, min = 0.0, unit = "F", quantity = "Capacitance") = 'c3' "Capacitance"; - Real 'C4.v'(start = 0.0, unit = "V", quantity = "ElectricPotential") "Voltage drop of the two pins (= p.v - n.v)"; - Real 'C4.p.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'C4.p.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'C4.n.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'C4.n.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'C4.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing from pin p to pin n"; - parameter Real 'C4.C'(start = 1.0, min = 0.0, unit = "F", quantity = "Capacitance") = 'c4' "Capacitance"; - Real 'C5.v'(fixed = true, start = 0.0, unit = "V", quantity = "ElectricPotential") "Voltage drop of the two pins (= p.v - n.v)"; - Real 'C5.p.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'C5.p.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'C5.n.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'C5.n.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'C5.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing from pin p to pin n"; - parameter Real 'C5.C'(start = 1.0, min = 0.0, unit = "F", quantity = "Capacitance") = 'c5' "Capacitance"; - Real 'L1.v'(unit = "V", quantity = "ElectricPotential") "Voltage drop of the two pins (= p.v - n.v)"; - Real 'L1.p.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'L1.p.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'L1.n.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'L1.n.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'L1.i'(fixed = true, start = 0.0, unit = "A", quantity = "ElectricCurrent") "Current flowing from pin p to pin n"; - parameter Real 'L1.L'(start = 1.0, unit = "H", quantity = "Inductance") = 'l1' "Inductance"; - Real 'L2.v'(unit = "V", quantity = "ElectricPotential") "Voltage drop of the two pins (= p.v - n.v)"; - Real 'L2.p.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'L2.p.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'L2.n.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'L2.n.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'L2.i'(fixed = true, start = 0.0, unit = "A", quantity = "ElectricCurrent") "Current flowing from pin p to pin n"; - parameter Real 'L2.L'(start = 1.0, unit = "H", quantity = "Inductance") = 'l2' "Inductance"; - parameter Real 'R1.R'(start = 1.0, unit = "Ohm", quantity = "Resistance") = 1.0 "Resistance at temperature T_ref"; - parameter Real 'R1.T_ref'(nominal = 300.0, start = 288.15, min = 0.0, displayUnit = "degC", unit = "K", quantity = "ThermodynamicTemperature") = 300.15 "Reference temperature"; - parameter Real 'R1.alpha'(unit = "1/K", quantity = "LinearTemperatureCoefficient") = 0.0 "Temperature coefficient of resistance (R_actual = R*(1 + alpha*(T_heatPort - T_ref))"; - Real 'R1.v'(unit = "V", quantity = "ElectricPotential") "Voltage drop of the two pins (= p.v - n.v)"; - Real 'R1.p.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'R1.p.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'R1.n.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'R1.n.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'R1.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing from pin p to pin n"; - parameter Boolean 'R1.useHeatPort' = false "= true, if heatPort is enabled" annotation(Evaluate = true); - parameter Real 'R1.T'(nominal = 300.0, start = 288.15, min = 0.0, displayUnit = "degC", unit = "K", quantity = "ThermodynamicTemperature") = 'R1.T_ref' "Fixed device temperature if useHeatPort = false"; - Real 'R1.LossPower'(unit = "W", quantity = "Power") "Loss power leaving component via heatPort"; - Real 'R1.T_heatPort'(nominal = 300.0, start = 288.15, min = 0.0, displayUnit = "degC", unit = "K", quantity = "ThermodynamicTemperature") "Temperature of heatPort"; - Real 'R1.R_actual'(unit = "Ohm", quantity = "Resistance") "Actual resistance = R*(1 + alpha*(T_heatPort - T_ref))"; - parameter Real 'R2.R'(start = 1.0, unit = "Ohm", quantity = "Resistance") = 1.0 "Resistance at temperature T_ref"; - parameter Real 'R2.T_ref'(nominal = 300.0, start = 288.15, min = 0.0, displayUnit = "degC", unit = "K", quantity = "ThermodynamicTemperature") = 300.15 "Reference temperature"; - parameter Real 'R2.alpha'(unit = "1/K", quantity = "LinearTemperatureCoefficient") = 0.0 "Temperature coefficient of resistance (R_actual = R*(1 + alpha*(T_heatPort - T_ref))"; - Real 'R2.v'(unit = "V", quantity = "ElectricPotential") "Voltage drop of the two pins (= p.v - n.v)"; - Real 'R2.p.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'R2.p.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'R2.n.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'R2.n.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'R2.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing from pin p to pin n"; - parameter Boolean 'R2.useHeatPort' = false "= true, if heatPort is enabled" annotation(Evaluate = true); - parameter Real 'R2.T'(nominal = 300.0, start = 288.15, min = 0.0, displayUnit = "degC", unit = "K", quantity = "ThermodynamicTemperature") = 'R2.T_ref' "Fixed device temperature if useHeatPort = false"; - Real 'R2.LossPower'(unit = "W", quantity = "Power") "Loss power leaving component via heatPort"; - Real 'R2.T_heatPort'(nominal = 300.0, start = 288.15, min = 0.0, displayUnit = "degC", unit = "K", quantity = "ThermodynamicTemperature") "Temperature of heatPort"; - Real 'R2.R_actual'(unit = "Ohm", quantity = "Resistance") "Actual resistance = R*(1 + alpha*(T_heatPort - T_ref))"; - parameter Real 'V.V'(start = 1.0, unit = "V", quantity = "ElectricPotential") = 1.0 "Height of step"; - Real 'V.v'(unit = "V", quantity = "ElectricPotential") "Voltage drop of the two pins (= p.v - n.v)"; - Real 'V.p.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'V.p.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'V.n.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'V.n.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'V.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing from pin p to pin n"; - parameter Real 'V.signalSource.height' = 'V.V' "Height of step"; - Real 'V.signalSource.y' "Connector of Real output signal"; - parameter Real 'V.signalSource.offset' = 'V.offset' "Offset of output signal y"; - parameter Real 'V.signalSource.startTime'(unit = "s", quantity = "Time") = 'V.startTime' "Output y = offset for time < startTime"; - parameter Real 'V.offset'(unit = "V", quantity = "ElectricPotential") = 0.0 "Voltage offset"; - parameter Real 'V.startTime'(unit = "s", quantity = "Time") = 1.0 "Time offset"; - equation - 'L1.p.v' = 'C1.p.v'; - 'L1.p.v' = 'C2.p.v'; - 'L1.p.v' = 'R1.n.v'; - 'C2.n.v' = 'L2.p.v'; - 'C2.n.v' = 'C4.p.v'; - 'C2.n.v' = 'C3.p.v'; - 'C2.n.v' = 'L1.n.v'; - 'C4.n.v' = 'R2.p.v'; - 'C4.n.v' = 'C5.p.v'; - 'C4.n.v' = 'L2.n.v'; - 'V.n.v' = 'G.p.v'; - 'V.n.v' = 'R2.n.v'; - 'V.n.v' = 'C1.n.v'; - 'V.n.v' = 'C5.n.v'; - 'V.n.v' = 'C3.n.v'; - 'R1.p.v' = 'V.p.v'; - 'V.n.i' + 'R2.n.i' + 'C5.n.i' + 'C3.n.i' + 'C1.n.i' + 'G.p.i' = 0.0; - 'L2.p.i' + 'L1.n.i' + 'C4.p.i' + 'C3.p.i' + 'C2.n.i' = 0.0; - 'R2.p.i' + 'L2.n.i' + 'C5.p.i' + 'C4.n.i' = 0.0; - 'V.p.i' + 'R1.p.i' = 0.0; - 'R1.n.i' + 'L1.p.i' + 'C2.p.i' + 'C1.p.i' = 0.0; - 'G.p.v' = 0.0; - 'C1.i' = 'C1.C' * der('C1.v'); - 0.0 = 'C1.p.i' + 'C1.n.i'; - 'C1.i' = 'C1.p.i'; - 'C1.v' = 'C1.p.v' - 'C1.n.v'; - 'C2.i' = 'C2.C' * der('C2.v'); - 0.0 = 'C2.p.i' + 'C2.n.i'; - 'C2.i' = 'C2.p.i'; - 'C2.v' = 'C2.p.v' - 'C2.n.v'; - 'C3.i' = 'C3.C' * der('C3.v'); - 0.0 = 'C3.p.i' + 'C3.n.i'; - 'C3.i' = 'C3.p.i'; - 'C3.v' = 'C3.p.v' - 'C3.n.v'; - 'C4.i' = 'C4.C' * der('C4.v'); - 0.0 = 'C4.p.i' + 'C4.n.i'; - 'C4.i' = 'C4.p.i'; - 'C4.v' = 'C4.p.v' - 'C4.n.v'; - 'C5.i' = 'C5.C' * der('C5.v'); - 0.0 = 'C5.p.i' + 'C5.n.i'; - 'C5.i' = 'C5.p.i'; - 'C5.v' = 'C5.p.v' - 'C5.n.v'; - 'L1.L' * der('L1.i') = 'L1.v'; - 0.0 = 'L1.p.i' + 'L1.n.i'; - 'L1.i' = 'L1.p.i'; - 'L1.v' = 'L1.p.v' - 'L1.n.v'; - 'L2.L' * der('L2.i') = 'L2.v'; - 0.0 = 'L2.p.i' + 'L2.n.i'; - 'L2.i' = 'L2.p.i'; - 'L2.v' = 'L2.p.v' - 'L2.n.v'; - assert(1.0 + 'R1.alpha' * ('R1.T_heatPort' - 'R1.T_ref') >= 2.220446049250313e-16, "Temperature outside scope of model!", AssertionLevel.error); - 'R1.R_actual' = 'R1.R' * (1.0 + 'R1.alpha' * ('R1.T_heatPort' - 'R1.T_ref')); - 'R1.v' = 'R1.R_actual' * 'R1.i'; - 'R1.LossPower' = 'R1.v' * 'R1.i'; - 'R1.T_heatPort' = 'R1.T'; - 0.0 = 'R1.p.i' + 'R1.n.i'; - 'R1.i' = 'R1.p.i'; - 'R1.v' = 'R1.p.v' - 'R1.n.v'; - assert(1.0 + 'R2.alpha' * ('R2.T_heatPort' - 'R2.T_ref') >= 2.220446049250313e-16, "Temperature outside scope of model!", AssertionLevel.error); - 'R2.R_actual' = 'R2.R' * (1.0 + 'R2.alpha' * ('R2.T_heatPort' - 'R2.T_ref')); - 'R2.v' = 'R2.R_actual' * 'R2.i'; - 'R2.LossPower' = 'R2.v' * 'R2.i'; - 'R2.T_heatPort' = 'R2.T'; - 0.0 = 'R2.p.i' + 'R2.n.i'; - 'R2.i' = 'R2.p.i'; - 'R2.v' = 'R2.p.v' - 'R2.n.v'; - 'V.signalSource.y' = 'V.signalSource.offset' + (if time < 'V.signalSource.startTime' then 0.0 else 'V.signalSource.height'); - 'V.v' = 'V.signalSource.y'; - 0.0 = 'V.p.i' + 'V.n.i'; - 'V.i' = 'V.p.i'; - 'V.v' = 'V.p.v' - 'V.n.v'; - annotation(experiment(StopTime = 60)); - end 'CauerLowPassAnalog'; -end 'CauerLowPassAnalog'; diff --git a/TestBaseModelica/examples/CauerLowPassAnalogSine.bmo b/TestBaseModelica/examples/CauerLowPassAnalogSine.bmo deleted file mode 100644 index 4f0bf5e..0000000 --- a/TestBaseModelica/examples/CauerLowPassAnalogSine.bmo +++ /dev/null @@ -1,182 +0,0 @@ -//! base 0.1.0 -package 'CauerLowPassAnalogSine' - model 'CauerLowPassAnalogSine' "Cauer low pass filter with analog components" - parameter Real 'l1'(unit = "H", quantity = "Inductance") = 1.304 "Filter coefficient I1"; - parameter Real 'l2'(unit = "H", quantity = "Inductance") = 0.8586 "Filter coefficient I2"; - parameter Real 'c1'(min = 0.0, unit = "F", quantity = "Capacitance") = 1.072 "Filter coefficient c1"; - parameter Real 'c2'(min = 0.0, unit = "F", quantity = "Capacitance") = 1.0 / (2.906997720064 * 'l1') "Filter coefficient c2"; - parameter Real 'c3'(min = 0.0, unit = "F", quantity = "Capacitance") = 1.682 "Filter coefficient c3"; - parameter Real 'c4'(min = 0.0, unit = "F", quantity = "Capacitance") = 1.0 / (1.392270203025 * 'l2') "Filter coefficient c4"; - parameter Real 'c5'(min = 0.0, unit = "F", quantity = "Capacitance") = 0.7262 "Filter coefficient c5"; - Real 'G.p.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'G.p.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'C1.v'(fixed = true, start = 0.0, unit = "V", quantity = "ElectricPotential") "Voltage drop of the two pins (= p.v - n.v)"; - Real 'C1.p.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'C1.p.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'C1.n.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'C1.n.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'C1.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing from pin p to pin n"; - parameter Real 'C1.C'(start = 1.0, min = 0.0, unit = "F", quantity = "Capacitance") = 'c1' "Capacitance"; - Real 'C2.v'(start = 0.0, unit = "V", quantity = "ElectricPotential") "Voltage drop of the two pins (= p.v - n.v)"; - Real 'C2.p.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'C2.p.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'C2.n.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'C2.n.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'C2.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing from pin p to pin n"; - parameter Real 'C2.C'(start = 1.0, min = 0.0, unit = "F", quantity = "Capacitance") = 'c2' "Capacitance"; - Real 'C3.v'(fixed = true, start = 0.0, unit = "V", quantity = "ElectricPotential") "Voltage drop of the two pins (= p.v - n.v)"; - Real 'C3.p.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'C3.p.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'C3.n.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'C3.n.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'C3.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing from pin p to pin n"; - parameter Real 'C3.C'(start = 1.0, min = 0.0, unit = "F", quantity = "Capacitance") = 'c3' "Capacitance"; - Real 'C4.v'(start = 0.0, unit = "V", quantity = "ElectricPotential") "Voltage drop of the two pins (= p.v - n.v)"; - Real 'C4.p.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'C4.p.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'C4.n.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'C4.n.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'C4.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing from pin p to pin n"; - parameter Real 'C4.C'(start = 1.0, min = 0.0, unit = "F", quantity = "Capacitance") = 'c4' "Capacitance"; - Real 'C5.v'(fixed = true, start = 0.0, unit = "V", quantity = "ElectricPotential") "Voltage drop of the two pins (= p.v - n.v)"; - Real 'C5.p.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'C5.p.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'C5.n.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'C5.n.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'C5.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing from pin p to pin n"; - parameter Real 'C5.C'(start = 1.0, min = 0.0, unit = "F", quantity = "Capacitance") = 'c5' "Capacitance"; - Real 'L1.v'(unit = "V", quantity = "ElectricPotential") "Voltage drop of the two pins (= p.v - n.v)"; - Real 'L1.p.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'L1.p.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'L1.n.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'L1.n.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'L1.i'(fixed = true, start = 0.0, unit = "A", quantity = "ElectricCurrent") "Current flowing from pin p to pin n"; - parameter Real 'L1.L'(start = 1.0, unit = "H", quantity = "Inductance") = 'l1' "Inductance"; - Real 'L2.v'(unit = "V", quantity = "ElectricPotential") "Voltage drop of the two pins (= p.v - n.v)"; - Real 'L2.p.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'L2.p.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'L2.n.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'L2.n.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'L2.i'(fixed = true, start = 0.0, unit = "A", quantity = "ElectricCurrent") "Current flowing from pin p to pin n"; - parameter Real 'L2.L'(start = 1.0, unit = "H", quantity = "Inductance") = 'l2' "Inductance"; - parameter Real 'R1.R'(start = 1.0, unit = "Ohm", quantity = "Resistance") = 1.0 "Resistance at temperature T_ref"; - parameter Real 'R1.T_ref'(nominal = 300.0, start = 288.15, min = 0.0, displayUnit = "degC", unit = "K", quantity = "ThermodynamicTemperature") = 300.15 "Reference temperature"; - parameter Real 'R1.alpha'(unit = "1/K", quantity = "LinearTemperatureCoefficient") = 0.0 "Temperature coefficient of resistance (R_actual = R*(1 + alpha*(T_heatPort - T_ref))"; - Real 'R1.v'(unit = "V", quantity = "ElectricPotential") "Voltage drop of the two pins (= p.v - n.v)"; - Real 'R1.p.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'R1.p.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'R1.n.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'R1.n.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'R1.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing from pin p to pin n"; - parameter Boolean 'R1.useHeatPort' = false "= true, if heatPort is enabled" annotation(Evaluate = true); - parameter Real 'R1.T'(nominal = 300.0, start = 288.15, min = 0.0, displayUnit = "degC", unit = "K", quantity = "ThermodynamicTemperature") = 'R1.T_ref' "Fixed device temperature if useHeatPort = false"; - Real 'R1.LossPower'(unit = "W", quantity = "Power") "Loss power leaving component via heatPort"; - Real 'R1.T_heatPort'(nominal = 300.0, start = 288.15, min = 0.0, displayUnit = "degC", unit = "K", quantity = "ThermodynamicTemperature") "Temperature of heatPort"; - Real 'R1.R_actual'(unit = "Ohm", quantity = "Resistance") "Actual resistance = R*(1 + alpha*(T_heatPort - T_ref))"; - parameter Real 'R2.R'(start = 1.0, unit = "Ohm", quantity = "Resistance") = 1.0 "Resistance at temperature T_ref"; - parameter Real 'R2.T_ref'(nominal = 300.0, start = 288.15, min = 0.0, displayUnit = "degC", unit = "K", quantity = "ThermodynamicTemperature") = 300.15 "Reference temperature"; - parameter Real 'R2.alpha'(unit = "1/K", quantity = "LinearTemperatureCoefficient") = 0.0 "Temperature coefficient of resistance (R_actual = R*(1 + alpha*(T_heatPort - T_ref))"; - Real 'R2.v'(unit = "V", quantity = "ElectricPotential") "Voltage drop of the two pins (= p.v - n.v)"; - Real 'R2.p.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'R2.p.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'R2.n.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'R2.n.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'R2.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing from pin p to pin n"; - parameter Boolean 'R2.useHeatPort' = false "= true, if heatPort is enabled" annotation(Evaluate = true); - parameter Real 'R2.T'(nominal = 300.0, start = 288.15, min = 0.0, displayUnit = "degC", unit = "K", quantity = "ThermodynamicTemperature") = 'R2.T_ref' "Fixed device temperature if useHeatPort = false"; - Real 'R2.LossPower'(unit = "W", quantity = "Power") "Loss power leaving component via heatPort"; - Real 'R2.T_heatPort'(nominal = 300.0, start = 288.15, min = 0.0, displayUnit = "degC", unit = "K", quantity = "ThermodynamicTemperature") "Temperature of heatPort"; - Real 'R2.R_actual'(unit = "Ohm", quantity = "Resistance") "Actual resistance = R*(1 + alpha*(T_heatPort - T_ref))"; - parameter Real 'V.V'(start = 1.0, unit = "V", quantity = "ElectricPotential") = 10.0 "Amplitude of sine wave"; - parameter Real 'V.phase'(displayUnit = "deg", unit = "rad", quantity = "Angle") = 0.0 "Phase of sine wave"; - parameter Real 'V.f'(start = 1.0, unit = "Hz", quantity = "Frequency") = 0.5 "Frequency of sine wave"; - Real 'V.v'(unit = "V", quantity = "ElectricPotential") "Voltage drop of the two pins (= p.v - n.v)"; - Real 'V.p.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'V.p.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'V.n.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'V.n.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'V.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing from pin p to pin n"; - parameter Real 'V.signalSource.amplitude' = 'V.V' "Amplitude of sine wave"; - parameter Real 'V.signalSource.f'(start = 1.0, unit = "Hz", quantity = "Frequency") = 'V.f' "Frequency of sine wave"; - parameter Real 'V.signalSource.phase'(displayUnit = "deg", unit = "rad", quantity = "Angle") = 'V.phase' "Phase of sine wave"; - parameter Boolean 'V.signalSource.continuous' = false "Make output continuous by starting at offset + amplitude*sin(phase)" annotation(Evaluate = true); - Real 'V.signalSource.y' "Connector of Real output signal"; - parameter Real 'V.signalSource.offset' = 'V.offset' "Offset of output signal y"; - parameter Real 'V.signalSource.startTime'(unit = "s", quantity = "Time") = 'V.startTime' "Output y = offset for time < startTime"; - parameter Real 'V.offset'(unit = "V", quantity = "ElectricPotential") = 0.0 "Voltage offset"; - parameter Real 'V.startTime'(unit = "s", quantity = "Time") = 0.0 "Time offset"; - equation - 'L1.p.v' = 'C1.p.v'; - 'L1.p.v' = 'C2.p.v'; - 'L1.p.v' = 'R1.n.v'; - 'C2.n.v' = 'L2.p.v'; - 'C2.n.v' = 'C4.p.v'; - 'C2.n.v' = 'C3.p.v'; - 'C2.n.v' = 'L1.n.v'; - 'C4.n.v' = 'R2.p.v'; - 'C4.n.v' = 'C5.p.v'; - 'C4.n.v' = 'L2.n.v'; - 'V.n.v' = 'G.p.v'; - 'V.n.v' = 'R2.n.v'; - 'V.n.v' = 'C1.n.v'; - 'V.n.v' = 'C5.n.v'; - 'V.n.v' = 'C3.n.v'; - 'R1.p.v' = 'V.p.v'; - 'V.n.i' + 'R2.n.i' + 'C5.n.i' + 'C3.n.i' + 'C1.n.i' + 'G.p.i' = 0.0; - 'L2.p.i' + 'L1.n.i' + 'C4.p.i' + 'C3.p.i' + 'C2.n.i' = 0.0; - 'R2.p.i' + 'L2.n.i' + 'C5.p.i' + 'C4.n.i' = 0.0; - 'V.p.i' + 'R1.p.i' = 0.0; - 'R1.n.i' + 'L1.p.i' + 'C2.p.i' + 'C1.p.i' = 0.0; - 'G.p.v' = 0.0; - 'C1.i' = 'C1.C' * der('C1.v'); - 0.0 = 'C1.p.i' + 'C1.n.i'; - 'C1.i' = 'C1.p.i'; - 'C1.v' = 'C1.p.v' - 'C1.n.v'; - 'C2.i' = 'C2.C' * der('C2.v'); - 0.0 = 'C2.p.i' + 'C2.n.i'; - 'C2.i' = 'C2.p.i'; - 'C2.v' = 'C2.p.v' - 'C2.n.v'; - 'C3.i' = 'C3.C' * der('C3.v'); - 0.0 = 'C3.p.i' + 'C3.n.i'; - 'C3.i' = 'C3.p.i'; - 'C3.v' = 'C3.p.v' - 'C3.n.v'; - 'C4.i' = 'C4.C' * der('C4.v'); - 0.0 = 'C4.p.i' + 'C4.n.i'; - 'C4.i' = 'C4.p.i'; - 'C4.v' = 'C4.p.v' - 'C4.n.v'; - 'C5.i' = 'C5.C' * der('C5.v'); - 0.0 = 'C5.p.i' + 'C5.n.i'; - 'C5.i' = 'C5.p.i'; - 'C5.v' = 'C5.p.v' - 'C5.n.v'; - 'L1.L' * der('L1.i') = 'L1.v'; - 0.0 = 'L1.p.i' + 'L1.n.i'; - 'L1.i' = 'L1.p.i'; - 'L1.v' = 'L1.p.v' - 'L1.n.v'; - 'L2.L' * der('L2.i') = 'L2.v'; - 0.0 = 'L2.p.i' + 'L2.n.i'; - 'L2.i' = 'L2.p.i'; - 'L2.v' = 'L2.p.v' - 'L2.n.v'; - assert(1.0 + 'R1.alpha' * ('R1.T_heatPort' - 'R1.T_ref') >= 2.220446049250313e-16, "Temperature outside scope of model!", AssertionLevel.error); - 'R1.R_actual' = 'R1.R' * (1.0 + 'R1.alpha' * ('R1.T_heatPort' - 'R1.T_ref')); - 'R1.v' = 'R1.R_actual' * 'R1.i'; - 'R1.LossPower' = 'R1.v' * 'R1.i'; - 'R1.T_heatPort' = 'R1.T'; - 0.0 = 'R1.p.i' + 'R1.n.i'; - 'R1.i' = 'R1.p.i'; - 'R1.v' = 'R1.p.v' - 'R1.n.v'; - assert(1.0 + 'R2.alpha' * ('R2.T_heatPort' - 'R2.T_ref') >= 2.220446049250313e-16, "Temperature outside scope of model!", AssertionLevel.error); - 'R2.R_actual' = 'R2.R' * (1.0 + 'R2.alpha' * ('R2.T_heatPort' - 'R2.T_ref')); - 'R2.v' = 'R2.R_actual' * 'R2.i'; - 'R2.LossPower' = 'R2.v' * 'R2.i'; - 'R2.T_heatPort' = 'R2.T'; - 0.0 = 'R2.p.i' + 'R2.n.i'; - 'R2.i' = 'R2.p.i'; - 'R2.v' = 'R2.p.v' - 'R2.n.v'; - 'V.signalSource.y' = 'V.signalSource.offset' + (if time < 'V.signalSource.startTime' then 0.0 else 'V.signalSource.amplitude' * sin(6.283185307179586 * 'V.signalSource.f' * (time - 'V.signalSource.startTime') + 'V.signalSource.phase')); - 'V.v' = 'V.signalSource.y'; - 0.0 = 'V.p.i' + 'V.n.i'; - 'V.i' = 'V.p.i'; - 'V.v' = 'V.p.v' - 'V.n.v'; - annotation(experiment(StopTime = 60)); - end 'CauerLowPassAnalogSine'; -end 'CauerLowPassAnalogSine'; diff --git a/TestBaseModelica/examples/CauerLowPassAnalogSineNoAssert.bmo b/TestBaseModelica/examples/CauerLowPassAnalogSineNoAssert.bmo deleted file mode 100644 index 1050fb2..0000000 --- a/TestBaseModelica/examples/CauerLowPassAnalogSineNoAssert.bmo +++ /dev/null @@ -1,180 +0,0 @@ -//! base 0.1.0 -package 'CauerLowPassAnalogSine' - model 'CauerLowPassAnalogSine' "Cauer low pass filter with analog components" - parameter Real 'l1'(unit = "H", quantity = "Inductance") = 1.304 "Filter coefficient I1"; - parameter Real 'l2'(unit = "H", quantity = "Inductance") = 0.8586 "Filter coefficient I2"; - parameter Real 'c1'(min = 0.0, unit = "F", quantity = "Capacitance") = 1.072 "Filter coefficient c1"; - parameter Real 'c2'(min = 0.0, unit = "F", quantity = "Capacitance") = 1.0 / (2.906997720064 * 'l1') "Filter coefficient c2"; - parameter Real 'c3'(min = 0.0, unit = "F", quantity = "Capacitance") = 1.682 "Filter coefficient c3"; - parameter Real 'c4'(min = 0.0, unit = "F", quantity = "Capacitance") = 1.0 / (1.392270203025 * 'l2') "Filter coefficient c4"; - parameter Real 'c5'(min = 0.0, unit = "F", quantity = "Capacitance") = 0.7262 "Filter coefficient c5"; - Real 'G.p.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'G.p.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'C1.v'(fixed = true, start = 0.0, unit = "V", quantity = "ElectricPotential") "Voltage drop of the two pins (= p.v - n.v)"; - Real 'C1.p.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'C1.p.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'C1.n.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'C1.n.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'C1.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing from pin p to pin n"; - parameter Real 'C1.C'(start = 1.0, min = 0.0, unit = "F", quantity = "Capacitance") = 'c1' "Capacitance"; - Real 'C2.v'(start = 0.0, unit = "V", quantity = "ElectricPotential") "Voltage drop of the two pins (= p.v - n.v)"; - Real 'C2.p.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'C2.p.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'C2.n.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'C2.n.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'C2.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing from pin p to pin n"; - parameter Real 'C2.C'(start = 1.0, min = 0.0, unit = "F", quantity = "Capacitance") = 'c2' "Capacitance"; - Real 'C3.v'(fixed = true, start = 0.0, unit = "V", quantity = "ElectricPotential") "Voltage drop of the two pins (= p.v - n.v)"; - Real 'C3.p.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'C3.p.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'C3.n.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'C3.n.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'C3.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing from pin p to pin n"; - parameter Real 'C3.C'(start = 1.0, min = 0.0, unit = "F", quantity = "Capacitance") = 'c3' "Capacitance"; - Real 'C4.v'(start = 0.0, unit = "V", quantity = "ElectricPotential") "Voltage drop of the two pins (= p.v - n.v)"; - Real 'C4.p.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'C4.p.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'C4.n.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'C4.n.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'C4.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing from pin p to pin n"; - parameter Real 'C4.C'(start = 1.0, min = 0.0, unit = "F", quantity = "Capacitance") = 'c4' "Capacitance"; - Real 'C5.v'(fixed = true, start = 0.0, unit = "V", quantity = "ElectricPotential") "Voltage drop of the two pins (= p.v - n.v)"; - Real 'C5.p.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'C5.p.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'C5.n.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'C5.n.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'C5.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing from pin p to pin n"; - parameter Real 'C5.C'(start = 1.0, min = 0.0, unit = "F", quantity = "Capacitance") = 'c5' "Capacitance"; - Real 'L1.v'(unit = "V", quantity = "ElectricPotential") "Voltage drop of the two pins (= p.v - n.v)"; - Real 'L1.p.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'L1.p.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'L1.n.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'L1.n.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'L1.i'(fixed = true, start = 0.0, unit = "A", quantity = "ElectricCurrent") "Current flowing from pin p to pin n"; - parameter Real 'L1.L'(start = 1.0, unit = "H", quantity = "Inductance") = 'l1' "Inductance"; - Real 'L2.v'(unit = "V", quantity = "ElectricPotential") "Voltage drop of the two pins (= p.v - n.v)"; - Real 'L2.p.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'L2.p.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'L2.n.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'L2.n.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'L2.i'(fixed = true, start = 0.0, unit = "A", quantity = "ElectricCurrent") "Current flowing from pin p to pin n"; - parameter Real 'L2.L'(start = 1.0, unit = "H", quantity = "Inductance") = 'l2' "Inductance"; - parameter Real 'R1.R'(start = 1.0, unit = "Ohm", quantity = "Resistance") = 1.0 "Resistance at temperature T_ref"; - parameter Real 'R1.T_ref'(nominal = 300.0, start = 288.15, min = 0.0, displayUnit = "degC", unit = "K", quantity = "ThermodynamicTemperature") = 300.15 "Reference temperature"; - parameter Real 'R1.alpha'(unit = "1/K", quantity = "LinearTemperatureCoefficient") = 0.0 "Temperature coefficient of resistance (R_actual = R*(1 + alpha*(T_heatPort - T_ref))"; - Real 'R1.v'(unit = "V", quantity = "ElectricPotential") "Voltage drop of the two pins (= p.v - n.v)"; - Real 'R1.p.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'R1.p.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'R1.n.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'R1.n.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'R1.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing from pin p to pin n"; - parameter Boolean 'R1.useHeatPort' = false "= true, if heatPort is enabled" annotation(Evaluate = true); - parameter Real 'R1.T'(nominal = 300.0, start = 288.15, min = 0.0, displayUnit = "degC", unit = "K", quantity = "ThermodynamicTemperature") = 'R1.T_ref' "Fixed device temperature if useHeatPort = false"; - Real 'R1.LossPower'(unit = "W", quantity = "Power") "Loss power leaving component via heatPort"; - Real 'R1.T_heatPort'(nominal = 300.0, start = 288.15, min = 0.0, displayUnit = "degC", unit = "K", quantity = "ThermodynamicTemperature") "Temperature of heatPort"; - Real 'R1.R_actual'(unit = "Ohm", quantity = "Resistance") "Actual resistance = R*(1 + alpha*(T_heatPort - T_ref))"; - parameter Real 'R2.R'(start = 1.0, unit = "Ohm", quantity = "Resistance") = 1.0 "Resistance at temperature T_ref"; - parameter Real 'R2.T_ref'(nominal = 300.0, start = 288.15, min = 0.0, displayUnit = "degC", unit = "K", quantity = "ThermodynamicTemperature") = 300.15 "Reference temperature"; - parameter Real 'R2.alpha'(unit = "1/K", quantity = "LinearTemperatureCoefficient") = 0.0 "Temperature coefficient of resistance (R_actual = R*(1 + alpha*(T_heatPort - T_ref))"; - Real 'R2.v'(unit = "V", quantity = "ElectricPotential") "Voltage drop of the two pins (= p.v - n.v)"; - Real 'R2.p.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'R2.p.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'R2.n.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'R2.n.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'R2.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing from pin p to pin n"; - parameter Boolean 'R2.useHeatPort' = false "= true, if heatPort is enabled" annotation(Evaluate = true); - parameter Real 'R2.T'(nominal = 300.0, start = 288.15, min = 0.0, displayUnit = "degC", unit = "K", quantity = "ThermodynamicTemperature") = 'R2.T_ref' "Fixed device temperature if useHeatPort = false"; - Real 'R2.LossPower'(unit = "W", quantity = "Power") "Loss power leaving component via heatPort"; - Real 'R2.T_heatPort'(nominal = 300.0, start = 288.15, min = 0.0, displayUnit = "degC", unit = "K", quantity = "ThermodynamicTemperature") "Temperature of heatPort"; - Real 'R2.R_actual'(unit = "Ohm", quantity = "Resistance") "Actual resistance = R*(1 + alpha*(T_heatPort - T_ref))"; - parameter Real 'V.V'(start = 1.0, unit = "V", quantity = "ElectricPotential") = 10.0 "Amplitude of sine wave"; - parameter Real 'V.phase'(displayUnit = "deg", unit = "rad", quantity = "Angle") = 0.0 "Phase of sine wave"; - parameter Real 'V.f'(start = 1.0, unit = "Hz", quantity = "Frequency") = 0.5 "Frequency of sine wave"; - Real 'V.v'(unit = "V", quantity = "ElectricPotential") "Voltage drop of the two pins (= p.v - n.v)"; - Real 'V.p.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'V.p.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'V.n.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'V.n.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'V.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing from pin p to pin n"; - parameter Real 'V.signalSource.amplitude' = 'V.V' "Amplitude of sine wave"; - parameter Real 'V.signalSource.f'(start = 1.0, unit = "Hz", quantity = "Frequency") = 'V.f' "Frequency of sine wave"; - parameter Real 'V.signalSource.phase'(displayUnit = "deg", unit = "rad", quantity = "Angle") = 'V.phase' "Phase of sine wave"; - parameter Boolean 'V.signalSource.continuous' = false "Make output continuous by starting at offset + amplitude*sin(phase)" annotation(Evaluate = true); - Real 'V.signalSource.y' "Connector of Real output signal"; - parameter Real 'V.signalSource.offset' = 'V.offset' "Offset of output signal y"; - parameter Real 'V.signalSource.startTime'(unit = "s", quantity = "Time") = 'V.startTime' "Output y = offset for time < startTime"; - parameter Real 'V.offset'(unit = "V", quantity = "ElectricPotential") = 0.0 "Voltage offset"; - parameter Real 'V.startTime'(unit = "s", quantity = "Time") = 0.0 "Time offset"; - equation - 'L1.p.v' = 'C1.p.v'; - 'L1.p.v' = 'C2.p.v'; - 'L1.p.v' = 'R1.n.v'; - 'C2.n.v' = 'L2.p.v'; - 'C2.n.v' = 'C4.p.v'; - 'C2.n.v' = 'C3.p.v'; - 'C2.n.v' = 'L1.n.v'; - 'C4.n.v' = 'R2.p.v'; - 'C4.n.v' = 'C5.p.v'; - 'C4.n.v' = 'L2.n.v'; - 'V.n.v' = 'G.p.v'; - 'V.n.v' = 'R2.n.v'; - 'V.n.v' = 'C1.n.v'; - 'V.n.v' = 'C5.n.v'; - 'V.n.v' = 'C3.n.v'; - 'R1.p.v' = 'V.p.v'; - 'V.n.i' + 'R2.n.i' + 'C5.n.i' + 'C3.n.i' + 'C1.n.i' + 'G.p.i' = 0.0; - 'L2.p.i' + 'L1.n.i' + 'C4.p.i' + 'C3.p.i' + 'C2.n.i' = 0.0; - 'R2.p.i' + 'L2.n.i' + 'C5.p.i' + 'C4.n.i' = 0.0; - 'V.p.i' + 'R1.p.i' = 0.0; - 'R1.n.i' + 'L1.p.i' + 'C2.p.i' + 'C1.p.i' = 0.0; - 'G.p.v' = 0.0; - 'C1.i' = 'C1.C' * der('C1.v'); - 0.0 = 'C1.p.i' + 'C1.n.i'; - 'C1.i' = 'C1.p.i'; - 'C1.v' = 'C1.p.v' - 'C1.n.v'; - 'C2.i' = 'C2.C' * der('C2.v'); - 0.0 = 'C2.p.i' + 'C2.n.i'; - 'C2.i' = 'C2.p.i'; - 'C2.v' = 'C2.p.v' - 'C2.n.v'; - 'C3.i' = 'C3.C' * der('C3.v'); - 0.0 = 'C3.p.i' + 'C3.n.i'; - 'C3.i' = 'C3.p.i'; - 'C3.v' = 'C3.p.v' - 'C3.n.v'; - 'C4.i' = 'C4.C' * der('C4.v'); - 0.0 = 'C4.p.i' + 'C4.n.i'; - 'C4.i' = 'C4.p.i'; - 'C4.v' = 'C4.p.v' - 'C4.n.v'; - 'C5.i' = 'C5.C' * der('C5.v'); - 0.0 = 'C5.p.i' + 'C5.n.i'; - 'C5.i' = 'C5.p.i'; - 'C5.v' = 'C5.p.v' - 'C5.n.v'; - 'L1.L' * der('L1.i') = 'L1.v'; - 0.0 = 'L1.p.i' + 'L1.n.i'; - 'L1.i' = 'L1.p.i'; - 'L1.v' = 'L1.p.v' - 'L1.n.v'; - 'L2.L' * der('L2.i') = 'L2.v'; - 0.0 = 'L2.p.i' + 'L2.n.i'; - 'L2.i' = 'L2.p.i'; - 'L2.v' = 'L2.p.v' - 'L2.n.v'; - 'R1.R_actual' = 'R1.R' * (1.0 + 'R1.alpha' * ('R1.T_heatPort' - 'R1.T_ref')); - 'R1.v' = 'R1.R_actual' * 'R1.i'; - 'R1.LossPower' = 'R1.v' * 'R1.i'; - 'R1.T_heatPort' = 'R1.T'; - 0.0 = 'R1.p.i' + 'R1.n.i'; - 'R1.i' = 'R1.p.i'; - 'R1.v' = 'R1.p.v' - 'R1.n.v'; - 'R2.R_actual' = 'R2.R' * (1.0 + 'R2.alpha' * ('R2.T_heatPort' - 'R2.T_ref')); - 'R2.v' = 'R2.R_actual' * 'R2.i'; - 'R2.LossPower' = 'R2.v' * 'R2.i'; - 'R2.T_heatPort' = 'R2.T'; - 0.0 = 'R2.p.i' + 'R2.n.i'; - 'R2.i' = 'R2.p.i'; - 'R2.v' = 'R2.p.v' - 'R2.n.v'; - 'V.signalSource.y' = 'V.signalSource.offset' + (if time < 'V.signalSource.startTime' then 0.0 else 'V.signalSource.amplitude' * sin(6.283185307179586 * 'V.signalSource.f' * (time - 'V.signalSource.startTime') + 'V.signalSource.phase')); - 'V.v' = 'V.signalSource.y'; - 0.0 = 'V.p.i' + 'V.n.i'; - 'V.i' = 'V.p.i'; - 'V.v' = 'V.p.v' - 'V.n.v'; - annotation(experiment(StopTime = 60)); - end 'CauerLowPassAnalogSine'; -end 'CauerLowPassAnalogSine'; diff --git a/TestBaseModelica/examples/ChuaCircuit.bmo b/TestBaseModelica/examples/ChuaCircuit.bmo deleted file mode 100644 index bcbd547..0000000 --- a/TestBaseModelica/examples/ChuaCircuit.bmo +++ /dev/null @@ -1,113 +0,0 @@ -//! base 0.1.0 -package 'ChuaCircuit' - model 'ChuaCircuit' "Chua's circuit, ns, V, A" - Real 'L.v'(unit = "V", quantity = "ElectricPotential") "Voltage drop of the two pins (= p.v - n.v)"; - Real 'L.p.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'L.p.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'L.n.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'L.n.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'L.i'(fixed = true, start = 0.0, unit = "A", quantity = "ElectricCurrent") "Current flowing from pin p to pin n"; - parameter Real 'L.L'(start = 1.0, unit = "H", quantity = "Inductance") = 18.0 "Inductance"; - parameter Real 'Ro.R'(start = 1.0, unit = "Ohm", quantity = "Resistance") = 0.0125 "Resistance at temperature T_ref"; - parameter Real 'Ro.T_ref'(nominal = 300.0, start = 288.15, min = 0.0, displayUnit = "degC", unit = "K", quantity = "ThermodynamicTemperature") = 300.15 "Reference temperature"; - parameter Real 'Ro.alpha'(unit = "1/K", quantity = "LinearTemperatureCoefficient") = 0.0 "Temperature coefficient of resistance (R_actual = R*(1 + alpha*(T_heatPort - T_ref))"; - Real 'Ro.v'(unit = "V", quantity = "ElectricPotential") "Voltage drop of the two pins (= p.v - n.v)"; - Real 'Ro.p.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'Ro.p.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'Ro.n.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'Ro.n.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'Ro.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing from pin p to pin n"; - parameter Boolean 'Ro.useHeatPort' = false "= true, if heatPort is enabled" annotation(Evaluate = true); - parameter Real 'Ro.T'(nominal = 300.0, start = 288.15, min = 0.0, displayUnit = "degC", unit = "K", quantity = "ThermodynamicTemperature") = 'Ro.T_ref' "Fixed device temperature if useHeatPort = false"; - Real 'Ro.LossPower'(unit = "W", quantity = "Power") "Loss power leaving component via heatPort"; - Real 'Ro.T_heatPort'(nominal = 300.0, start = 288.15, min = 0.0, displayUnit = "degC", unit = "K", quantity = "ThermodynamicTemperature") "Temperature of heatPort"; - Real 'Ro.R_actual'(unit = "Ohm", quantity = "Resistance") "Actual resistance = R*(1 + alpha*(T_heatPort - T_ref))"; - parameter Real 'G.G'(start = 1.0, unit = "S", quantity = "Conductance") = 0.565 "Conductance at temperature T_ref"; - parameter Real 'G.T_ref'(nominal = 300.0, start = 288.15, min = 0.0, displayUnit = "degC", unit = "K", quantity = "ThermodynamicTemperature") = 300.15 "Reference temperature"; - parameter Real 'G.alpha'(unit = "1/K", quantity = "LinearTemperatureCoefficient") = 0.0 "Temperature coefficient of conductance (G_actual = G_ref/(1 + alpha*(T_heatPort - T_ref))"; - Real 'G.v'(unit = "V", quantity = "ElectricPotential") "Voltage drop of the two pins (= p.v - n.v)"; - Real 'G.p.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'G.p.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'G.n.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'G.n.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'G.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing from pin p to pin n"; - parameter Boolean 'G.useHeatPort' = false "= true, if heatPort is enabled" annotation(Evaluate = true); - parameter Real 'G.T'(nominal = 300.0, start = 288.15, min = 0.0, displayUnit = "degC", unit = "K", quantity = "ThermodynamicTemperature") = 'G.T_ref' "Fixed device temperature if useHeatPort = false"; - Real 'G.LossPower'(unit = "W", quantity = "Power") "Loss power leaving component via heatPort"; - Real 'G.T_heatPort'(nominal = 300.0, start = 288.15, min = 0.0, displayUnit = "degC", unit = "K", quantity = "ThermodynamicTemperature") "Temperature of heatPort"; - Real 'G.G_actual'(unit = "S", quantity = "Conductance") "Actual conductance = G_ref/(1 + alpha*(T_heatPort - T_ref))"; - Real 'C1.v'(fixed = true, start = 4.0, unit = "V", quantity = "ElectricPotential") "Voltage drop of the two pins (= p.v - n.v)"; - Real 'C1.p.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'C1.p.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'C1.n.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'C1.n.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'C1.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing from pin p to pin n"; - parameter Real 'C1.C'(start = 1.0, min = 0.0, unit = "F", quantity = "Capacitance") = 10.0 "Capacitance"; - Real 'C2.v'(fixed = true, start = 0.0, unit = "V", quantity = "ElectricPotential") "Voltage drop of the two pins (= p.v - n.v)"; - Real 'C2.p.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'C2.p.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'C2.n.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'C2.n.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'C2.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing from pin p to pin n"; - parameter Real 'C2.C'(start = 1.0, min = 0.0, unit = "F", quantity = "Capacitance") = 100.0 "Capacitance"; - Real 'Nr.v'(unit = "V", quantity = "ElectricPotential") "Voltage drop of the two pins (= p.v - n.v)"; - Real 'Nr.p.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'Nr.p.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'Nr.n.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'Nr.n.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'Nr.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing from pin p to pin n"; - parameter Real 'Nr.Ga'(min = -1.0, unit = "S", quantity = "Conductance") = -0.757576 "Conductance in inner voltage range"; - parameter Real 'Nr.Gb'(min = -1.0, unit = "S", quantity = "Conductance") = -0.409091 "Conductance in outer voltage range"; - parameter Real 'Nr.Ve'(unit = "V", quantity = "ElectricPotential") = 1.0 "Inner voltage range limit"; - Real 'Gnd.p.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'Gnd.p.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - equation - 'L.n.v' = 'Ro.p.v'; - 'L.p.v' = 'G.p.v'; - 'L.p.v' = 'C2.p.v'; - 'C1.p.v' = 'G.n.v'; - 'C1.p.v' = 'Nr.p.v'; - 'Gnd.p.v' = 'Nr.n.v'; - 'Gnd.p.v' = 'C1.n.v'; - 'Gnd.p.v' = 'C2.n.v'; - 'Gnd.p.v' = 'Ro.n.v'; - 'Ro.p.i' + 'L.n.i' = 0.0; - 'Gnd.p.i' + 'Nr.n.i' + 'C2.n.i' + 'C1.n.i' + 'Ro.n.i' = 0.0; - 'C2.p.i' + 'G.p.i' + 'L.p.i' = 0.0; - 'Nr.p.i' + 'C1.p.i' + 'G.n.i' = 0.0; - 'L.L' * der('L.i') = 'L.v'; - 0.0 = 'L.p.i' + 'L.n.i'; - 'L.i' = 'L.p.i'; - 'L.v' = 'L.p.v' - 'L.n.v'; - assert(1.0 + 'Ro.alpha' * ('Ro.T_heatPort' - 'Ro.T_ref') >= 2.220446049250313e-16, "Temperature outside scope of model!", AssertionLevel.error); - 'Ro.R_actual' = 'Ro.R' * (1.0 + 'Ro.alpha' * ('Ro.T_heatPort' - 'Ro.T_ref')); - 'Ro.v' = 'Ro.R_actual' * 'Ro.i'; - 'Ro.LossPower' = 'Ro.v' * 'Ro.i'; - 'Ro.T_heatPort' = 'Ro.T'; - 0.0 = 'Ro.p.i' + 'Ro.n.i'; - 'Ro.i' = 'Ro.p.i'; - 'Ro.v' = 'Ro.p.v' - 'Ro.n.v'; - assert(1.0 + 'G.alpha' * ('G.T_heatPort' - 'G.T_ref') >= 2.220446049250313e-16, "Temperature outside scope of model!", AssertionLevel.error); - 'G.G_actual' = 'G.G' / (1.0 + 'G.alpha' * ('G.T_heatPort' - 'G.T_ref')); - 'G.i' = 'G.G_actual' * 'G.v'; - 'G.LossPower' = 'G.v' * 'G.i'; - 'G.T_heatPort' = 'G.T'; - 0.0 = 'G.p.i' + 'G.n.i'; - 'G.i' = 'G.p.i'; - 'G.v' = 'G.p.v' - 'G.n.v'; - 'C1.i' = 'C1.C' * der('C1.v'); - 0.0 = 'C1.p.i' + 'C1.n.i'; - 'C1.i' = 'C1.p.i'; - 'C1.v' = 'C1.p.v' - 'C1.n.v'; - 'C2.i' = 'C2.C' * der('C2.v'); - 0.0 = 'C2.p.i' + 'C2.n.i'; - 'C2.i' = 'C2.p.i'; - 'C2.v' = 'C2.p.v' - 'C2.n.v'; - 'Nr.i' = if 'Nr.v' < (-'Nr.Ve') then 'Nr.Gb' * ('Nr.v' + 'Nr.Ve') - 'Nr.Ga' * 'Nr.Ve' else if 'Nr.v' > 'Nr.Ve' then 'Nr.Gb' * ('Nr.v' - 'Nr.Ve') + 'Nr.Ga' * 'Nr.Ve' else 'Nr.Ga' * 'Nr.v'; - 0.0 = 'Nr.p.i' + 'Nr.n.i'; - 'Nr.i' = 'Nr.p.i'; - 'Nr.v' = 'Nr.p.v' - 'Nr.n.v'; - 'Gnd.p.v' = 0.0; - annotation(experiment(StopTime = 5e4, Interval = 1)); - end 'ChuaCircuit'; -end 'ChuaCircuit'; diff --git a/TestBaseModelica/examples/ChuaCircuitNoAssert.bmo b/TestBaseModelica/examples/ChuaCircuitNoAssert.bmo deleted file mode 100644 index a593fc1..0000000 --- a/TestBaseModelica/examples/ChuaCircuitNoAssert.bmo +++ /dev/null @@ -1,113 +0,0 @@ -//! base 0.1.0 -package 'ChuaCircuit' - model 'ChuaCircuit' "Chua's circuit, ns, V, A" - Real 'L.v'(unit = "V", quantity = "ElectricPotential") "Voltage drop of the two pins (= p.v - n.v)"; - Real 'L.p.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'L.p.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'L.n.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'L.n.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'L.i'(fixed = true, start = 0.0, unit = "A", quantity = "ElectricCurrent") "Current flowing from pin p to pin n"; - parameter Real 'L.L'(start = 1.0, unit = "H", quantity = "Inductance") = 18.0 "Inductance"; - parameter Real 'Ro.R'(start = 1.0, unit = "Ohm", quantity = "Resistance") = 0.0125 "Resistance at temperature T_ref"; - parameter Real 'Ro.T_ref'(nominal = 300.0, start = 288.15, min = 0.0, displayUnit = "degC", unit = "K", quantity = "ThermodynamicTemperature") = 300.15 "Reference temperature"; - parameter Real 'Ro.alpha'(unit = "1/K", quantity = "LinearTemperatureCoefficient") = 0.0 "Temperature coefficient of resistance (R_actual = R*(1 + alpha*(T_heatPort - T_ref))"; - Real 'Ro.v'(unit = "V", quantity = "ElectricPotential") "Voltage drop of the two pins (= p.v - n.v)"; - Real 'Ro.p.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'Ro.p.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'Ro.n.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'Ro.n.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'Ro.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing from pin p to pin n"; - parameter Boolean 'Ro.useHeatPort' = false "= true, if heatPort is enabled" annotation(Evaluate = true); - parameter Real 'Ro.T'(nominal = 300.0, start = 288.15, min = 0.0, displayUnit = "degC", unit = "K", quantity = "ThermodynamicTemperature") = 'Ro.T_ref' "Fixed device temperature if useHeatPort = false"; - Real 'Ro.LossPower'(unit = "W", quantity = "Power") "Loss power leaving component via heatPort"; - Real 'Ro.T_heatPort'(nominal = 300.0, start = 288.15, min = 0.0, displayUnit = "degC", unit = "K", quantity = "ThermodynamicTemperature") "Temperature of heatPort"; - Real 'Ro.R_actual'(unit = "Ohm", quantity = "Resistance") "Actual resistance = R*(1 + alpha*(T_heatPort - T_ref))"; - parameter Real 'G.G'(start = 1.0, unit = "S", quantity = "Conductance") = 0.565 "Conductance at temperature T_ref"; - parameter Real 'G.T_ref'(nominal = 300.0, start = 288.15, min = 0.0, displayUnit = "degC", unit = "K", quantity = "ThermodynamicTemperature") = 300.15 "Reference temperature"; - parameter Real 'G.alpha'(unit = "1/K", quantity = "LinearTemperatureCoefficient") = 0.0 "Temperature coefficient of conductance (G_actual = G_ref/(1 + alpha*(T_heatPort - T_ref))"; - Real 'G.v'(unit = "V", quantity = "ElectricPotential") "Voltage drop of the two pins (= p.v - n.v)"; - Real 'G.p.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'G.p.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'G.n.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'G.n.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'G.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing from pin p to pin n"; - parameter Boolean 'G.useHeatPort' = false "= true, if heatPort is enabled" annotation(Evaluate = true); - parameter Real 'G.T'(nominal = 300.0, start = 288.15, min = 0.0, displayUnit = "degC", unit = "K", quantity = "ThermodynamicTemperature") = 'G.T_ref' "Fixed device temperature if useHeatPort = false"; - Real 'G.LossPower'(unit = "W", quantity = "Power") "Loss power leaving component via heatPort"; - Real 'G.T_heatPort'(nominal = 300.0, start = 288.15, min = 0.0, displayUnit = "degC", unit = "K", quantity = "ThermodynamicTemperature") "Temperature of heatPort"; - Real 'G.G_actual'(unit = "S", quantity = "Conductance") "Actual conductance = G_ref/(1 + alpha*(T_heatPort - T_ref))"; - Real 'C1.v'(fixed = true, start = 4.0, unit = "V", quantity = "ElectricPotential") "Voltage drop of the two pins (= p.v - n.v)"; - Real 'C1.p.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'C1.p.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'C1.n.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'C1.n.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'C1.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing from pin p to pin n"; - parameter Real 'C1.C'(start = 1.0, min = 0.0, unit = "F", quantity = "Capacitance") = 10.0 "Capacitance"; - Real 'C2.v'(fixed = true, start = 0.0, unit = "V", quantity = "ElectricPotential") "Voltage drop of the two pins (= p.v - n.v)"; - Real 'C2.p.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'C2.p.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'C2.n.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'C2.n.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'C2.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing from pin p to pin n"; - parameter Real 'C2.C'(start = 1.0, min = 0.0, unit = "F", quantity = "Capacitance") = 100.0 "Capacitance"; - Real 'Nr.v'(unit = "V", quantity = "ElectricPotential") "Voltage drop of the two pins (= p.v - n.v)"; - Real 'Nr.p.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'Nr.p.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'Nr.n.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'Nr.n.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - Real 'Nr.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing from pin p to pin n"; - parameter Real 'Nr.Ga'(min = -1.0, unit = "S", quantity = "Conductance") = -0.757576 "Conductance in inner voltage range"; - parameter Real 'Nr.Gb'(min = -1.0, unit = "S", quantity = "Conductance") = -0.409091 "Conductance in outer voltage range"; - parameter Real 'Nr.Ve'(unit = "V", quantity = "ElectricPotential") = 1.0 "Inner voltage range limit"; - Real 'Gnd.p.v'(unit = "V", quantity = "ElectricPotential") "Potential at the pin"; - Real 'Gnd.p.i'(unit = "A", quantity = "ElectricCurrent") "Current flowing into the pin"; - equation - 'L.n.v' = 'Ro.p.v'; - 'L.p.v' = 'G.p.v'; - 'L.p.v' = 'C2.p.v'; - 'C1.p.v' = 'G.n.v'; - 'C1.p.v' = 'Nr.p.v'; - 'Gnd.p.v' = 'Nr.n.v'; - 'Gnd.p.v' = 'C1.n.v'; - 'Gnd.p.v' = 'C2.n.v'; - 'Gnd.p.v' = 'Ro.n.v'; - 'Ro.p.i' + 'L.n.i' = 0.0; - 'Gnd.p.i' + 'Nr.n.i' + 'C2.n.i' + 'C1.n.i' + 'Ro.n.i' = 0.0; - 'C2.p.i' + 'G.p.i' + 'L.p.i' = 0.0; - 'Nr.p.i' + 'C1.p.i' + 'G.n.i' = 0.0; - 'L.L' * der('L.i') = 'L.v'; - 0.0 = 'L.p.i' + 'L.n.i'; - 'L.i' = 'L.p.i'; - 'L.v' = 'L.p.v' - 'L.n.v'; - assert(1.0 + 'Ro.alpha' * ('Ro.T_heatPort' - 'Ro.T_ref') >= 2.220446049250313e-16, "Temperature outside scope of model!", AssertionLevel.error); - 'Ro.R_actual' = 'Ro.R' * (1.0 + 'Ro.alpha' * ('Ro.T_heatPort' - 'Ro.T_ref')); - 'Ro.v' = 'Ro.R_actual' * 'Ro.i'; - 'Ro.LossPower' = 'Ro.v' * 'Ro.i'; - 'Ro.T_heatPort' = 'Ro.T'; - 0.0 = 'Ro.p.i' + 'Ro.n.i'; - 'Ro.i' = 'Ro.p.i'; - 'Ro.v' = 'Ro.p.v' - 'Ro.n.v'; - assert(1.0 + 'G.alpha' * ('G.T_heatPort' - 'G.T_ref') >= 2.220446049250313e-16, "Temperature outside scope of model!", AssertionLevel.error); - 'G.G_actual' = 'G.G' / (1.0 + 'G.alpha' * ('G.T_heatPort' - 'G.T_ref')); - 'G.i' = 'G.G_actual' * 'G.v'; - 'G.LossPower' = 'G.v' * 'G.i'; - 'G.T_heatPort' = 'G.T'; - 0.0 = 'G.p.i' + 'G.n.i'; - 'G.i' = 'G.p.i'; - 'G.v' = 'G.p.v' - 'G.n.v'; - 'C1.i' = 'C1.C' * der('C1.v'); - 0.0 = 'C1.p.i' + 'C1.n.i'; - 'C1.i' = 'C1.p.i'; - 'C1.v' = 'C1.p.v' - 'C1.n.v'; - 'C2.i' = 'C2.C' * der('C2.v'); - 0.0 = 'C2.p.i' + 'C2.n.i'; - 'C2.i' = 'C2.p.i'; - 'C2.v' = 'C2.p.v' - 'C2.n.v'; - 'Nr.i' = if 'Nr.v' < (-'Nr.Ve') then 'Nr.Gb' * ('Nr.v' + 'Nr.Ve') - 'Nr.Ga' * 'Nr.Ve' else if 'Nr.v' > 'Nr.Ve' then 'Nr.Gb' * ('Nr.v' - 'Nr.Ve') + 'Nr.Ga' * 'Nr.Ve' else 'Nr.Ga' * 'Nr.v'; - 0.0 = 'Nr.p.i' + 'Nr.n.i'; - 'Nr.i' = 'Nr.p.i'; - 'Nr.v' = 'Nr.p.v' - 'Nr.n.v'; - 'Gnd.p.v' = 0.0; - annotation(experiment(StopTime = 5e4, Interval = 1)); - end 'ChuaCircuit'; -end 'ChuaCircuit'; diff --git a/TestBaseModelica/examples/Experiment.bmo b/TestBaseModelica/examples/Experiment.bmo deleted file mode 100644 index 00e7081..0000000 --- a/TestBaseModelica/examples/Experiment.bmo +++ /dev/null @@ -1,12 +0,0 @@ -//! base 0.1.0 -package 'Experiment' - model 'Experiment' - parameter Real 'x0' = 1.0; - Real 'x'; - initial equation - 'x' = 'x0'; - equation - der('x') = 'x'; - annotation(experiment(StartTime = 0, StopTime = 2.0, Tolerance = 1e-06, Interval = 0.004)); - end 'Experiment'; -end 'Experiment'; \ No newline at end of file diff --git a/TestBaseModelica/examples/FirstOrder.bmo b/TestBaseModelica/examples/FirstOrder.bmo deleted file mode 100644 index b29ecfd..0000000 --- a/TestBaseModelica/examples/FirstOrder.bmo +++ /dev/null @@ -1,12 +0,0 @@ -//! base 0.1.0 -package 'FirstOrder' - model 'FirstOrder' - parameter Real 'x0' = 0 "Initial value for 'x'"; - parameter Real 'a' = 1.1 "Parameter to multiply with 'x'"; - Real 'x' "Real variable called 'x'"; - initial equation - 'x' = 'x0' "Set initial value of 'x' to 'x0'"; - equation - der('x') = 1.0 - 'a' * 'x'; - end 'FirstOrder'; -end 'FirstOrder'; diff --git a/TestBaseModelica/examples/IfEquation.bmo b/TestBaseModelica/examples/IfEquation.bmo deleted file mode 100644 index fb97d51..0000000 --- a/TestBaseModelica/examples/IfEquation.bmo +++ /dev/null @@ -1,14 +0,0 @@ -//! base 0.1.0 -package 'IfEquation' - model 'IfEquation' - Real 'x'; - Real 'y' (start = 1.0, fixed = true); - equation - if time < 0.5 then - 'x' = 1.0; - elseif true then - 'x' = 2.0; - end if; - der('y') = 'x'; - end 'IfEquation'; -end 'IfEquation'; diff --git a/TestBaseModelica/examples/MinimalValid.bmo b/TestBaseModelica/examples/MinimalValid.bmo deleted file mode 100644 index d55b945..0000000 --- a/TestBaseModelica/examples/MinimalValid.bmo +++ /dev/null @@ -1,5 +0,0 @@ -//! base 3.5.0 -package _F - model _F - end _F; -end _F; \ No newline at end of file diff --git a/TestBaseModelica/examples/Modifier.bmo b/TestBaseModelica/examples/Modifier.bmo deleted file mode 100644 index f8dcaa2..0000000 --- a/TestBaseModelica/examples/Modifier.bmo +++ /dev/null @@ -1,9 +0,0 @@ -//! base 0.1.0 -package 'Modifier' - model 'Modifier' - Real 'x'(fixed = true, start = 1.0); - parameter Real 'a'(nominal = 100.0, start = 400.0) = 10.0; - equation - der('x') = 'a'*'x'; - end 'Modifier'; -end 'Modifier'; \ No newline at end of file diff --git a/TestBaseModelica/examples/NegativeVariable.bmo b/TestBaseModelica/examples/NegativeVariable.bmo deleted file mode 100644 index 039a8e6..0000000 --- a/TestBaseModelica/examples/NegativeVariable.bmo +++ /dev/null @@ -1,8 +0,0 @@ -//! base 0.1.0 -package 'Negate' - model 'Negate' - Real 'x'; - equation - der('x') = -'x'; - end 'Negate'; -end 'Negate'; \ No newline at end of file diff --git a/TestBaseModelica/examples/NewtonCoolingBase.bmo b/TestBaseModelica/examples/NewtonCoolingBase.bmo deleted file mode 100644 index bd2e3d0..0000000 --- a/TestBaseModelica/examples/NewtonCoolingBase.bmo +++ /dev/null @@ -1,16 +0,0 @@ -//! base 0.1.0 -package 'NewtonCoolingWithDefaults' - model 'NewtonCoolingWithDefaults' "Cooling example with default parameter values" - parameter Real 'T_inf' = 25.0 "Ambient temperature"; - parameter Real 'T0' = 90.0 "Initial temperature"; - parameter Real 'h' = 0.7 "Convective cooling coefficient"; - parameter Real 'A' = 1.0 "Surface area"; - parameter Real 'm' = 0.1 "Mass of thermal capacitance"; - parameter Real 'c_p' = 1.2 "Specific heat"; - Real 'T' "Temperature"; - initial equation - 'T' = 'T0' "Specify initial value for T"; - equation - 'm' * 'c_p' * der('T') = 'h' * 'A' * ('T_inf' - 'T') "Newton's law of cooling"; - end 'NewtonCoolingWithDefaults'; -end 'NewtonCoolingWithDefaults'; diff --git a/TestBaseModelica/examples/ParameterWithModifiers.bmo b/TestBaseModelica/examples/ParameterWithModifiers.bmo deleted file mode 100644 index 22c2591..0000000 --- a/TestBaseModelica/examples/ParameterWithModifiers.bmo +++ /dev/null @@ -1,11 +0,0 @@ -//! base 0.1.0 -package 'Parameter' - model 'Parameter' - Real 'x'(fixed = true, start = 1.0); - parameter Real 'T_ref'(nominal = 300.0, start = 288.15, - min = 0.0, displayUnit = "degC", unit = "K", - quantity = "ThermodynamicTemperature") = 300.15; - equation - der('x') = 'x'; - end 'Parameter'; -end 'Parameter'; diff --git a/TestBaseModelica/examples/README.md b/TestBaseModelica/examples/README.md deleted file mode 100644 index 446d29f..0000000 --- a/TestBaseModelica/examples/README.md +++ /dev/null @@ -1,6 +0,0 @@ -# Notes - -Files taken from -[SciML/BaseModelica.jl](https://github.com/SciML/BaseModelica.jl/tree/36574b10a354bc9be8db0f3dc185ff55cf4a83b5/test/testfiles). -I don't think this is a substantial part of the software, so I didn't copy the -MIT License and copyright notice. diff --git a/TestBaseModelica/precompile_skript.jl b/TestBaseModelica/precompile_skript.jl deleted file mode 100644 index 520d5ac..0000000 --- a/TestBaseModelica/precompile_skript.jl +++ /dev/null @@ -1,34 +0,0 @@ -using TestBaseModelica - -# Collect all .bmo files from examples directory -examples = [ - (splitext(basename(file))[1], file) for file in filter( - f -> endswith(f, ".bmo"), - readdir(joinpath(@__DIR__, "examples"), join=true) - ) -] - -solver_settings = SolverSettings( - start_time = 0.0, - stop_time = 1.0, - interval = 0.02, - tolerance = 1e-6 -) - -for (modelname, bmo_file) in examples - output_directory = "tmp_out_dir" - test_settings = TestSettings( - modelname = modelname, - output_directory = output_directory, - solver_settings = solver_settings - ) - try - @info "Running $modelname ..." - run_test(bmo_file; settings = test_settings) - @info "... done!" - catch err - @warn "... failed!" - showerror(stdout, err) - end - rm(output_directory, force=true, recursive=true) -end diff --git a/TestBaseModelica/src/TestBaseModelica.jl b/TestBaseModelica/src/TestBaseModelica.jl deleted file mode 100644 index 64e2f0c..0000000 --- a/TestBaseModelica/src/TestBaseModelica.jl +++ /dev/null @@ -1,52 +0,0 @@ -module TestBaseModelica - -import BaseModelica -import CSV -import DataFrames -import SciMLBase -import OrdinaryDiffEq - -include("settings.jl") - -""" -Test coupling of Base Modelica and ModelingToolkit.jl. - - 1. Parse given Base Modelica file using BaseModelica.jl and ModelingToolkit.jl - 2. Solve ODE problem -""" -function run_test(base_modelica_file::AbstractString; settings::TestSettings) - mkpath(abspath(settings.output_directory)) - - # Parse Base Modelica and create ODEProblem - ode_problem = nothing - time_parsing = @elapsed begin - ode_problem = BaseModelica.create_odeproblem(base_modelica_file) - end - open(settings.time_measurements_file, "w") do file - write(file, "BaseModelica.create_odeproblem, $(time_parsing)\n") - end - - # Simulate ODEProblem - ode_solution = nothing - time_solve = @elapsed begin - if isnothing(settings.solver_settings.solver) - ode_solution = OrdinaryDiffEq.solve(ode_problem) - else - ode_solution = OrdinaryDiffEq.solve(ode_problem, settings.solver_settings.solver) - end - end - open(settings.time_measurements_file, "a") do file - write(file, "OrdinaryDiffEq.solve, $(time_solve)\n") - end - - # Save simulation result - df = DataFrames.DataFrame(ode_solution) - DataFrames.rename!(df,:timestamp => :time) - CSV.write(joinpath(settings.output_directory, settings.modelname * "_res.csv"), df) -end - -export TestSettings -export SolverSettings -export run_test - -end diff --git a/TestBaseModelica/src/settings.jl b/TestBaseModelica/src/settings.jl deleted file mode 100644 index a8200fc..0000000 --- a/TestBaseModelica/src/settings.jl +++ /dev/null @@ -1,63 +0,0 @@ -""" -Solver settings to solve ODE system. -""" -struct SolverSettings - solver - start_time::Real - stop_time::Real - interval::Real - tolerance::Real - - function SolverSettings(; - solver=nothing, - start_time::Real=0.0, - stop_time::Real=1.0, - interval::Real=(stop_time-start_time)/500, - tolerance::Real=1e-6 - ) - @assert stop_time >= start_time "Stop time is smaller than start time." - @assert interval > 0 "Interval has to be greater than zero." - @assert tolerance > 0 "Tolerance has to be greater than zero." - - new( - solver, - start_time, - stop_time, - interval, - tolerance - ) - end -end - -struct TestSettings - modelname::AbstractString - output_directory::AbstractString - resultfile::AbstractString - time_measurements_file::AbstractString - timeout_parsing::Integer - timeout_simulating::Integer - solver_settings::SolverSettings - - function TestSettings(; - modelname::AbstractString, - output_directory::AbstractString=pwd(), - resultfile::AbstractString=joinpath(output_directory, modelname * "_res.csv"), - time_measurements_file::AbstractString=joinpath(output_directory, modelname * "_times.csv"), - timeout_parsing::Integer=300, # 5 minutes - timeout_simulating::Integer=300, # 5 minutes - solver_settings::SolverSettings=SolverSettings() - ) - - @assert timeout_parsing > 0 "Timeout for parsing must be greater than zero." - @assert timeout_simulating > 0 "Timeout for simulating must be greater than zero." - - new( - modelname, - output_directory, - resultfile, - time_measurements_file, - timeout_parsing, - timeout_simulating, - solver_settings) - end -end diff --git a/TestBaseModelica/test/runtests.jl b/TestBaseModelica/test/runtests.jl deleted file mode 100644 index c7a2b92..0000000 --- a/TestBaseModelica/test/runtests.jl +++ /dev/null @@ -1,4 +0,0 @@ -using Test -using SafeTestsets - -include("test_parse.jl") diff --git a/TestBaseModelica/test/test_parse.jl b/TestBaseModelica/test/test_parse.jl deleted file mode 100644 index 0e2bd01..0000000 --- a/TestBaseModelica/test/test_parse.jl +++ /dev/null @@ -1,41 +0,0 @@ -using Test -using TestBaseModelica -using DataFrames -using CSV - -function test_parse_and_simulate_FirstOrder() - modelname = "FirstOrder" - base_modelica_file = joinpath(dirname(@__DIR__), "examples", modelname * ".bmo") - - output_directory = joinpath(@__DIR__, "test_out") - rm(output_directory, force=true, recursive=true) - - run_test(base_modelica_file; - settings=TestSettings( - modelname = modelname, - output_directory=output_directory, - timeout_parsing = 60) - ) - - times_file = joinpath(output_directory, modelname * "_times.csv") - @test isfile(times_file) - content = readlines(times_file) - @info content - @test occursin(r"BaseModelica\.create_odeproblem, [0-9]+\.[0-9]+", content[1]) - @test occursin(r"OrdinaryDiffEq\.solve, [0-9]+\.[0-9]+", content[2]) - - result_file = joinpath(output_directory, modelname * "_res.csv") - @test isfile(result_file) - df = CSV.read(result_file, DataFrame) - filter!(row -> row.time in [0.0, 1.0], df) - @test df[1,2] == 0.0 - @test df[2,2] ≈ 0.6064807012910736 - - rm(output_directory, force=true, recursive=true) -end - -@testset "run_test" begin - @testset "FirstOrder" begin - test_parse_and_simulate_FirstOrder() - end -end diff --git a/basemodelica.py b/basemodelica.py deleted file mode 100644 index 1f3fd59..0000000 --- a/basemodelica.py +++ /dev/null @@ -1,72 +0,0 @@ -import monotonic -import os.path -import os -import shutil -import warnings - -from omcommon import friendlyStr - -try: - from juliacall import Main as jl -except ImportError: - warnings.warn("No module named 'juliacall'. " - "'--basemodelica-mtk-import' won't be supported.") - juliacall = None - class jl: - def seval(any: any): - raise ImportError("No module named 'juliacall'") - -def print_julia_version() -> None: - """Print Julia `versioninfo()`""" - - julia = shutil.which("julia") - print("Julia executable: %s" %(julia)) - - # Jenkins might redirect STDOUT and Julia prints aren't displayed - versioninfo = jl.seval("using InteractiveUtils; buf = IOBuffer(); versioninfo(buf); String(take!(buf))") - print(versioninfo) - -def precompile_testbaesmodelica(systemImage: os.PathLike | None = None) -> None: - """Update and pre-compile TestBaseModelica to `sysimage`. - - Update dependencies of TestBaseModelica to get the latest version of - BaseModelica.jl from branch main. - Create a pre-compile system image of package TestBaseModelica with - PackageCompiler.jl. Skipping this step if `systemImage` is `None`. - This might take a wile! - """ - - start = monotonic.monotonic() - - print("Updating Julia package TestBaseModelica.jl") - try: - os.remove("TestBaseModelica/Manifest.toml") - except FileNotFoundError: - pass - - jl.seval('import Pkg;' - 'Pkg.activate();' - 'Pkg.add("PackageCompiler");' - 'using PackageCompiler;' - 'Pkg.activate("TestBaseModelica");' - 'Pkg.update();' - 'Pkg.status();') - - if systemImage == None: - print("Developing TestBaseModelica.jl") - jl.seval('Pkg.activate();' - 'Pkg.develop(path="TestBaseModelica");' - 'Pkg.precompile("TestBaseModelica")') - else: - print("Pre-compiling Julia system image %s for TestBaseModelica. " - "This might take a while." % systemImage) - - jl.seval('create_sysimage(["TestBaseModelica"];' - 'sysimage_path="%s",' - 'precompile_execution_file="TestBaseModelica/precompile_skript.jl")' - % systemImage) - if not os.path.isfile(systemImage): - raise FileNotFoundError("Something went wrong, couldn't find %s" % systemImage) - - execTime = monotonic.monotonic() - start - print("Done pre-compiling in %s." % friendlyStr(execTime)) diff --git a/requirements.txt b/requirements.txt index 7c5e0e0..bf3dd41 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,5 @@ datetime joblib -juliacall matplotlib monotonic natsort diff --git a/test.py b/test.py index 4ec6764..c9792f5 100755 --- a/test.py +++ b/test.py @@ -27,8 +27,6 @@ parser.add_argument('--branch', default='master') parser.add_argument('--fmi', default=False) parser.add_argument('--fmuType', default='me', help="FMU type: 'me' for Model Exchange, 'cs' for Co-Simulation.") -parser.add_argument('--basemodelica-mtk-import', action="store_true", default=False, help='Activate Base Modelica export and test import with BaseModelica.jl / ModelingToolkit.jl.') -parser.add_argument('--julia-sys-image', action=argparse.BooleanOptionalAction, default=True, help='Activate pre-compiling Julia system image.') parser.add_argument('--output', default='') parser.add_argument('--docker', default='') parser.add_argument('--libraries', help="Directory omc will search in to load system libraries/libraries to test.", default='') @@ -68,8 +66,6 @@ extrasimflags = args.extrasimflags ompython_omhome = args.ompython_omhome fmisimulator = args.fmisimulator or None -basemodelica_mtk_import = args.basemodelica_mtk_import -julia_sys_image = args.julia_sys_image allTestsFmi = args.fmi fmuType = args.fmuType ulimitMemory = args.ulimitvmem @@ -316,15 +312,6 @@ def timeSeconds(f): sys.stdout.flush() -# Print Julia versions for BaseModelica.jl import -julia_sysimage = os.path.abspath("TestBaseModelica.so") if julia_sys_image else None -if basemodelica_mtk_import: - # Only import basemodelica if needed. - # Python package juliacall will install Julia and can fail with unsatisfiable requirments. - import basemodelica - basemodelica.print_julia_version() - basemodelica.precompile_testbaesmodelica(julia_sysimage) - try: os.unlink("HelloWorld"+exeExt) except OSError: @@ -363,9 +350,6 @@ def timeSeconds(f): if extraflags: defaultCustomCommands += [extraflags] -if basemodelica_mtk_import: - defaultCustomCommands += ['setCommandLineOptions("--baseModelica --frontendInline --baseModelicaOptions=scalarize -d=evaluateAllParameters");'] - def testHelloWorld(cmd): with open("HelloWorld.mos") as fin: helloWorldContents = fin.read() @@ -519,11 +503,6 @@ def testHelloWorld(cmd): if allTestsFmi: c["fmi"] = "2.0" - if basemodelica_mtk_import: - c["basemodelica-export"] = True - c["basemodelica-mtk-import"] = True - c["julia-system-image"] = julia_sysimage if julia_sys_image else "" - # Create mos-files conn = sqlite3.connect('sqlite3.db') diff --git a/testmodel.py b/testmodel.py index 72d25e5..121d522 100755 --- a/testmodel.py +++ b/testmodel.py @@ -400,8 +400,6 @@ def sendExpressionOldOrNew(cmd): start=monotonic() if conf.get("fmi"): cmd='"" <> buildModelFMU(%s,fileNamePrefix="%s",fmuType="%s",version="%s",platforms={"static"})' % (conf["modelName"],conf["fileName"].replace(".","_"),conf["fmuType"],conf["fmi"]) -elif conf.get("basemodelica-export"): - cmd = 'writeFile("%s.mo", OpenModelica.Scripting.instantiateModel(%s))' % (conf["modelName"], conf["modelName"]) else: cmd='translateModel(%s,tolerance=%g,outputFormat="%s",numberOfIntervals=%d,variableFilter="%s",fileNamePrefix="%s")' % (conf["modelName"],tolerance,outputFormat,numberOfIntervals,variableFilter,conf["fileName"]) with open(errFile, 'a+') as fp: @@ -459,10 +457,6 @@ def sendExpressionOldOrNew(cmd): else: execstat["phase"]=1 execstat["backend"]=backend -elif conf.get("basemodelica-export"): - # TODO: No way to measure success or time of instantiate yet - execstat["phase"] = 4 - execstat["frontend"]=total else: execstat["phase"]=0 execstat["frontend"]=frontend @@ -484,15 +478,6 @@ def sendExpressionOldOrNew(cmd): execstat["phase"]=4 writeResultAndExit(0, False, omc, omc_new) execstat["phase"] = 5 - elif conf.get("basemodelica-export"): - if res: - baseModelicaExpectedLocation = "%s.mo" % conf["modelName"] - execstat["build"] = buildmodel - if not os.path.exists(os.path.normpath(baseModelicaExpectedLocation)): - err += "\nBaseModelica was not generated in the expected location: %s" % baseModelicaExpectedLocation - execstat["phase"] = 4 - writeResultAndExit(0, False, omc, omc_new) - execstat["phase"] = 5 else: if isWin: res = checkOutputTimeout("\"%s\\share\\omc\\scripts\\Compile.bat\" %s gcc %s parallel dynamic 24 0" % (conf["omhome"], conf["fileName"], msysEnvironment), conf["ulimitOmc"], conf) @@ -536,44 +521,6 @@ def sendExpressionOldOrNew(cmd): with open(simFile,"w") as fp: fp.write("%s %s\n" % (fmisimulator, cmd)) res = checkOutputTimeout("(rm -f %s.pipe ; mkfifo %s.pipe ; head -c 1048576 < %s.pipe >> %s & %s %s > %s.pipe 2>&1)" % (conf["fileName"],conf["fileName"],conf["fileName"],simFile,fmisimulator,cmd,conf["fileName"]), 1.05*conf["ulimitExe"], conf) - elif conf.get("basemodelica-export"): - if conf.get("basemodelica-mtk-import"): - - juliaCallFile=os.path.normpath("%s_test.jl" % conf["modelName"]) - with open(juliaCallFile,"w") as fp: - if conf["julia-system-image"] == "": - fp.write("using TestBaseModelica\n") - else: - fp.write("using .TestBaseModelica\n") - fp.write("solver_settings = SolverSettings(start_time=%g,stop_time=%g,interval=%g,tolerance=%g)\n" %(startTime,stopTime,stepSize,tolerance)) - fp.write("test_settings = TestSettings(modelname=\"%s\", solver_settings=solver_settings)\n" % (conf["fileName"])) - fp.write("run_test(\"%s.mo\"; settings = test_settings)\n" % (conf["modelName"])) - - # Get correct julia executable / system image - if conf["julia-system-image"] != "": - cmd = "julia --sysimage=%s" % conf["julia-system-image"] - else: - try: - from juliacall import CONFIG - cmd = CONFIG["exepath"] - except (ImportError, Exception) as e: - print(e) - cmd = "julia" # Fallback to system Julia - - cmd += " %s" % juliaCallFile - with open(simFile,"w") as fp: - with open(juliaCallFile, "r") as juliaFile: - file_content = juliaFile.read() - fp.write("%s_test.jl:\n\n" % conf["modelName"]) - fp.write(file_content) - fp.write("\n") - - fp.write("%s\n" % (cmd)) - res = checkOutputTimeout( - "(rm -f %s.pipe ; mkfifo %s.pipe ; head -c 1048576 < %s.pipe >> %s & %s > %s.pipe 2>&1)" - % (conf["fileName"], conf["fileName"], conf["fileName"], simFile, cmd, conf["fileName"]), 1.05*conf["ulimitExe"], conf) - else: - print("BaseModelica import with OpenModelica not yet implemented.") else: if isWin: cmd = (".\\%s.bat %s %s %s" % (conf["fileName"],annotationSimFlags,conf["simFlags"],emit_protected)).strip()