Skip to content

Commit

Permalink
fixed all examples
Browse files Browse the repository at this point in the history
  • Loading branch information
ThummeTo committed Sep 11, 2024
1 parent da93960 commit 409ad8b
Show file tree
Hide file tree
Showing 6 changed files with 320 additions and 71 deletions.
261 changes: 249 additions & 12 deletions examples/src/inputs.ipynb

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions examples/src/multiprocessing.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 1,
"metadata": {
"execution": {
"iopub.execute_input": "2022-10-22T13:20:18.794000Z",
Expand Down Expand Up @@ -112,7 +112,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 3,
"metadata": {
"execution": {
"iopub.execute_input": "2022-10-22T13:20:27.186000Z",
Expand Down Expand Up @@ -202,7 +202,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"metadata": {
"execution": {
"iopub.execute_input": "2022-10-22T13:21:32.504000Z",
Expand Down Expand Up @@ -236,7 +236,7 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 7,
"metadata": {
"execution": {
"iopub.execute_input": "2022-10-22T13:21:40.054000Z",
Expand Down Expand Up @@ -286,7 +286,7 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": null,
"metadata": {
"execution": {
"iopub.execute_input": "2022-10-22T13:22:25.583000Z",
Expand Down Expand Up @@ -345,7 +345,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 11,
"metadata": {
"execution": {
"iopub.execute_input": "2022-10-22T13:24:10.627000Z",
Expand Down
13 changes: 7 additions & 6 deletions examples/src/multithreading.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 21,
"metadata": {
"execution": {
"iopub.execute_input": "2022-10-22T13:24:22.502000Z",
Expand Down Expand Up @@ -82,7 +82,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 22,
"metadata": {
"execution": {
"iopub.execute_input": "2022-10-22T13:24:22.779000Z",
Expand All @@ -97,7 +97,8 @@
"using FMI\n",
"using FMIZoo\n",
"using Folds\n",
"using BenchmarkTools"
"using BenchmarkTools\n",
"using DifferentialEquations"
]
},
{
Expand Down Expand Up @@ -337,15 +338,15 @@
],
"metadata": {
"kernelspec": {
"display_name": "Julia 1.8.2",
"display_name": "Julia 1.10.5",
"language": "julia",
"name": "julia-1.8"
"name": "julia-1.10"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "1.8.2"
"version": "1.10.5"
}
},
"nbformat": 4,
Expand Down
22 changes: 16 additions & 6 deletions examples/src/parameter_optimization.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 19,
"metadata": {
"execution": {
"iopub.execute_input": "2022-10-22T13:26:47.623000Z",
Expand Down Expand Up @@ -65,7 +65,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 20,
"metadata": {
"execution": {
"iopub.execute_input": "2022-10-22T13:26:47.908000Z",
Expand All @@ -81,7 +81,8 @@
"using FMI\n",
"using FMIZoo\n",
"using Optim\n",
"using Plots"
"using Plots\n",
"using DifferentialEquations"
]
},
{
Expand Down Expand Up @@ -306,6 +307,15 @@
"Actually a pretty fit! If you have higher requirements, check out the *Optim.jl* library."
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {},
"outputs": [],
"source": [
"unloadFMU(fmu)"
]
},
{
"attachments": {},
"cell_type": "markdown",
Expand All @@ -327,15 +337,15 @@
"notebook_metadata_filter": "-all"
},
"kernelspec": {
"display_name": "Julia 1.8.5",
"display_name": "Julia 1.10.5",
"language": "julia",
"name": "julia-1.8"
"name": "julia-1.10"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "1.8.5"
"version": "1.10.5"
},
"nteract": {
"version": "0.28.0"
Expand Down
68 changes: 34 additions & 34 deletions examples/src/parameterize.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 47,
"metadata": {
"execution": {
"iopub.execute_input": "2022-10-22T13:26:47.623000Z",
Expand Down Expand Up @@ -55,7 +55,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 48,
"metadata": {
"execution": {
"iopub.execute_input": "2022-10-22T13:26:47.908000Z",
Expand Down Expand Up @@ -111,7 +111,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {
"execution": {
"iopub.execute_input": "2022-10-22T13:27:25.403000Z",
Expand Down Expand Up @@ -174,7 +174,7 @@
},
"outputs": [],
"source": [
"fmi2Instantiate!(fmu; loggingOn=true)"
"c = fmi2Instantiate!(fmu; loggingOn=true)"
]
},
{
Expand All @@ -197,7 +197,7 @@
},
"outputs": [],
"source": [
"fmi2SetupExperiment(fmu, tStart, tStop)"
"fmi2SetupExperiment(c, tStart, tStop)"
]
},
{
Expand Down Expand Up @@ -246,7 +246,7 @@
},
"outputs": [],
"source": [
"fmi2EnterInitializationMode(fmu)"
"fmi2EnterInitializationMode(c)"
]
},
{
Expand All @@ -269,7 +269,7 @@
},
"outputs": [],
"source": [
"getValue(fmu, params)"
"getValue(c, params)"
]
},
{
Expand All @@ -292,7 +292,7 @@
},
"outputs": [],
"source": [
"fmi2ExitInitializationMode(fmu)"
"fmi2ExitInitializationMode(c)"
]
},
{
Expand Down Expand Up @@ -370,9 +370,9 @@
},
"outputs": [],
"source": [
"fmi2Terminate(fmu)\n",
"fmi2Reset(fmu)\n",
"fmi2SetupExperiment(fmu, tStart, tStop)"
"fmi2Terminate(c)\n",
"fmi2Reset(c)\n",
"fmi2SetupExperiment(c, tStart, tStop)"
]
},
{
Expand All @@ -395,7 +395,7 @@
},
"outputs": [],
"source": [
"setValue(fmu, params, collect(paramsVal))"
"setValue(c, params, collect(paramsVal))"
]
},
{
Expand All @@ -418,9 +418,9 @@
},
"outputs": [],
"source": [
"fmiEnterInitializationMode(fmu)\n",
"# getValue(fmu, params)\n",
"fmiExitInitializationMode(fmu)"
"fmi2EnterInitializationMode(c)\n",
"# getValue(c, params)\n",
"fmi2ExitInitializationMode(c)"
]
},
{
Expand All @@ -443,7 +443,7 @@
},
"outputs": [],
"source": [
"simData = simulate(fmu, (tStart, tStop); recordValues=params[1:3], saveat=tSave, \n",
"simData = simulate(c, (tStart, tStop); recordValues=params[1:3], saveat=tSave, \n",
" instantiate=false, setup=false, freeInstance=false, terminate=false, reset=false)"
]
},
Expand All @@ -469,9 +469,9 @@
},
"outputs": [],
"source": [
"fmi2Terminate(fmu)\n",
"fmi2Reset(fmu)\n",
"fmi2SetupExperiment(fmu, tStart, tStop)"
"fmi2Terminate(c)\n",
"fmi2Reset(c)\n",
"fmi2SetupExperiment(c, tStart, tStop)"
]
},
{
Expand Down Expand Up @@ -517,10 +517,10 @@
},
"outputs": [],
"source": [
"fmi2SetReal(fmu, \"p_real\", rndReal)\n",
"fmi2SetBoolean(fmu, \"p_boolean\", rndBoolean)\n",
"fmi2SetInteger(fmu, \"p_integer\", rndInteger)\n",
"fmi2SetString(fmu, \"p_string\", rndString)"
"fmi2SetReal(c, \"p_real\", rndReal)\n",
"fmi2SetBoolean(c, \"p_boolean\", rndBoolean)\n",
"fmi2SetInteger(c, \"p_integer\", rndInteger)\n",
"fmi2SetString(c, \"p_string\", rndString)"
]
},
{
Expand Down Expand Up @@ -549,12 +549,12 @@
},
"outputs": [],
"source": [
"fmi2EnterInitializationMode(fmu)\n",
"# fmi2GetReal(fmu, \"u_real\")\n",
"# fmi2GetBoolean(fmu, \"u_boolean\")\n",
"# fmi2GetInteger(fmu, \"u_integer\")\n",
"# fmi2GetString(fmu, \"p_string\")\n",
"fmi2ExitInitializationMode(fmu)"
"fmi2EnterInitializationMode(c)\n",
"# fmi2GetReal(c, \"u_real\")\n",
"# fmi2GetBoolean(c, \"u_boolean\")\n",
"# fmi2GetInteger(c, \"u_integer\")\n",
"# fmi2GetString(c, \"p_string\")\n",
"fmi2ExitInitializationMode(c)"
]
},
{
Expand All @@ -577,7 +577,7 @@
},
"outputs": [],
"source": [
"simData = simulate(fmu, (tStart, tStop); recordValues=params[1:3], saveat=tSave, \n",
"simData = simulate(c, (tStart, tStop); recordValues=params[1:3], saveat=tSave, \n",
" instantiate=false, setup=false)"
]
},
Expand All @@ -592,7 +592,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 69,
"metadata": {
"execution": {
"iopub.execute_input": "2022-10-22T13:27:52.293000Z",
Expand Down Expand Up @@ -628,15 +628,15 @@
"notebook_metadata_filter": "-all"
},
"kernelspec": {
"display_name": "Julia 1.9.1",
"display_name": "Julia 1.10.5",
"language": "julia",
"name": "julia-1.9"
"name": "julia-1.10"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "1.9.1"
"version": "1.10.5"
},
"nteract": {
"version": "0.28.0"
Expand Down
Loading

0 comments on commit 409ad8b

Please sign in to comment.