Giter VIP home page Giter VIP logo

modelicabook's Introduction

Getting Started

Location on the Web

This book is currently published at http://mbe.modelica.university. This is an early access version that gives people a chance to comment on the book before making an "official" release. The goal is to collect sufficient feedback that we can move forward with the publication of a paper (printed) version of the book without concerns that the material will still require significant revisions.

Contributing

If you find an issue with the current version of the book or have a suggestion for improving it, there are several ways you can contribute to the book. They are listed here in order of most likely to be incorporated first:

  • Send me a pull request. By submitting a pull request to me, you make it very easy for me to comment on and/or incorporate your suggested change. As such, I strongly recommend you take this route since it is much more time consuming for me to apply your changes myself (and, therefore, it makes such changes less likely).
  • Report the issue as an issue in the issue tracker. This helps me keep track of all the various issues. This approach should be a last resort for changes where the "fix" isn't obvious (and therefore you cannot make the change yourself).

If you send me email suggesting something, I will almost certainly send you back to this section. It is much harder for me to keep track of issues via email. So if you aren't willing to submit a pull request, please take the second option of submitting an issue to the issue tracker.

Translations

I welcome translations. My goal is that translations should be distributed under the same terms as the English language of the book. Specifically, this means:

  • An HTML version of the book will be hosted at modelica.university and published under a creative commons license.
  • ePub and PDF versions of the book should be made available for purchase using a "pay what you can" pricing model.
  • Publication of a paper version of the book are a possibility, but I can't commit to physical publishing without further discussion.

In all cases where there is potential revenue, I would be willing to enter into a revenue sharing agreement with the translators.

To learn more about what translations are planned, who to contact about helping with translations or instructions about the translation workflow, please see this dedicated document on translations.

Technical Details

Background

This book is being written using Sphinx. I chose this system after evaluating several others. The main things I liked about Sphinx were:

  • The numerous output formats it supports (HTML, ePub and PDF being the important ones).
  • The extensibility of the Sphinx system.
  • The fact that it supports internationalization.
  • The fact that it allows custom templates and CSS to be used.

Compilation

Sphinx is completely portable so in theory, it should be possible to run Sphinx under nearly any operating system.

Although previous versions required a bunch of tools to build the book, the current version only requires that you have Node and Docker installed. I highly recommend the Docker for Mac and Docker for Windows flavors if you are on macOS or Windows, respectively.

Recently, I had some success using the Remote - Containers extension in Visual Studio Code along with the mtiller/flat-book-builder image mentioned below. If you open this folder in Visual Studio Code and you have the Remote - Containers extension installed, you should get an option to re-open VS Code in the container. Doing so, you should be setup to build. As such, I've bundled the .devcontainer directory that include the configuration necessary to do the builds in containers. This could also be useful when building on Windows (if you have VS Code and the Remote - Containers extension installed).

In order to build this, the first thing you need to do is ensure all submodules have been checked out, i.e.,

$ git submodule init
$ git submodule update

There is now a root level Makefile. You should be able to simply run:

make all

...which should build the book (if I'm forgetting something, send me a pull request for this README adding any further instructions). The source will be generated in ./text/build/dirhtml.

M1 Macs

I've seen two odd things while building on M1 Macs. The first was related to clang not being able to determine the proper CPU target. I fixed that by forcing some specific CFLAGS values (although I also realized that I could fix it simply by setting the ARCH variable to x86-64 during the build process) when running on an M1.

The other issue is trickier. As I've reported here, you can occasionally get an out of memory error while building. This appears to be a bug in the current M1 support in Docker Desktop. It is an intermittent bug so the only solution I've found is to simply restart the build whenever it comes up. It seems to be localized to the OpenModelica compiler omc because it only triggers while running that. This is frustrating because it can take many, many attempts to build all the necessary results files.

Flat Image

The original mtiller/book-builder Docker image had multiple layers and this led to lots of warnings like this during builds:

Unexpected end of /proc/mounts line `cker/overlay2/l/TH5GPGEDJZF3YVOCTK2ZVB6S7X:/var/lib/docker/overlay2/l/JP6Q3UKNSJBYBAGJCE4R2BAOIS:/var/lib/docker/overlay2/l/IPRRIXJ6IQ3FUHM67CYISMADBD:/var/lib/docker/overlay2/l/U24HKOEVMHAXULWB3YYLUHRLJK:/var/lib/docker/overlay2/l/H4OLNB6XZPU7OHA2XDXMCXNUY4:/var/lib/docker/overlay2/l/EF4M5E33IEXKDQ6OMU2D3QRH7A:/var/lib/docker/overlay2/l/5OIOMB6J7SBUOYA3SZZY7J2WYK:/var/lib/docker/overlay2/l/ZK5AEX73ZAABW7ZY2Y6YWWFYWW:/var/lib/docker/overlay2/l/NTTTRZPNBKPKTMQ7YAKMGG5ILF:/var/lib/docker/overlay2/l/MUVGOVJFK'

So I created a new image called mtiller/flat-book-builder to avoid those messages. Both images still exist in case there are any issues with the "flat" version.

modelicabook's People

Contributors

adrpo avatar ahmed-sami-engineer avatar cschoel avatar dietmarw avatar eraracom avatar fnd avatar giplessis avatar gwr69 avatar hansolsson avatar harmanpa avatar johanrhodin avatar juliaojunior avatar justnielsen avatar kdavies4 avatar lionelbelmon avatar lochel avatar maltelenz avatar michael-okeefe avatar mjschuh avatar mromanoni avatar mrtiller avatar msasena avatar mtiller avatar mwetter avatar sjoelund avatar sulopezperez avatar tbeu avatar tpwo avatar victe avatar xie-dongping avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

modelicabook's Issues

Proper refrences for figures and tables for the printed version

For the printed version a proper reference in the shape of "Fig. X" and "Table Y" might be called for.

Sphinx does not support this by default butt at least there is an extension for figures: numfig

Still that would have to be modified to also work for tables. But then again I found a more general solution of using raw-latex

Pendula.System seems to have issues with SimulationX

Model 60: ModelicaByExample.Subsystems.Pendula.System
Error In Modelica.Math.Vectors.normalizeWithAssert
2_Modelica.Math.Vectors.normalizeWithAssert.result:=
pendulum.revolute.n_sqrt(pendulum.revolute.n_pendulum.revolute.n)^-1;
In an assignment, the variable ([15]-vector) must have the same dimension as the expression ([3]-vector).
Error In pendulum.revolute.cylinder.r_shape
pendulum.revolute.cylinder.r_shapeCalc=
-1__2_Modelica.Math.Vectors.normalizeWithAssert.result_pendulum.revolute.cylinderLength_0.5;
In an equation, the left ([3]-vector) and the right side ([15]-vector) must have the same dimension.
Error In pendulum.revolute
pendulum.revolute.tau=
-1_pendulum.revolute.frame_b.t__2_Modelica.Math.Vectors.normalizeWithAssert.result;
The operator "
" requires arguments of equal dimensions.
Error In Modelica.Math.Vectors.normalizeWithAssert
_3_Modelica.Math.Vectors.normalizeWithAssert.result:=
pendulum.string.lengthDirection_sqrt(pendulum.string.lengthDirection_pendulum.string.lengthDirection)^-1;
In an assignment, the variable ([15]-vector) must have the same dimension as the expression ([3]-vector).
Error In pendulum.string.r_CM
pendulum.string.r_CM=pendulum.string.r_shape+_3_Modelica.Math.Vectors.normalizeWithAssert.result_pendulum.string.length_0.5;
The operator "+" requires arguments of equal dimensions.
Error In pendulum.string.sequence_angleStates.min

Wrong place for model annotation

In http://beta.book.xogeny.com/behavior/equations/annotations/, you write the model annotation in the third line. As far as I understand, the syntax rules prescribe to put it just before the end statement. Section B 2.2 of the spec:

class_definition :
[ encapsulated ] class_prefixes
class_specifier

class_specifier :
long_class_specifier | short_class_specifier | der_class_specifier

long_class_specifier :
IDENT string_comment composition end IDENT
| extends IDENT [ class_modification ] string_comment composition
end IDENT

composition :
element_list
{ public element_list |
protected element_list |
equation_section |
algorithm_section
}
[ external [ language_specification ]
[ external_function_call ] [ annotation ] ";" ]
[ annotation ";" ]

Dymola specific code in examples

Mike,
I saw that the code examples contain Dymola- and silly empty annotations like

Diagram(graphics),
__Dymola_experimentSetupOutput); 

Most likely also other superfluous stuff added by Dymola. In case this is going to be part of the released book I think it should be removed. If you like I can help you with that (doing it for the MSL anyway) but would wait until the immediate release. I.e., until you are not going to touch the code with Dymola again.

Add experiment annotation to all examples that are meant to run

I should add experiment annotations to all the examples. However, when including
these examples into the text of the book, I'll typically want to strip the annotations. So
I'll need to find a simple way to strip annotations as part of the inclusion process.

IntegrateInterpolatedExternalVector potentially missing some information

Model 70: ModelicaByExample.Functions.Interpolation.IntegrateInterpolatedExternalVector
Warning In ModelicaByExample.Functions.Interpolation.IntegrateInterpolatedExternalVector
There is no start attribute of state z. It is set to 0.
The name of the library is missing.
In ModelicaByExample.Functions.Interpolation.VectorTable: The name of the library where the external function createVectorTable is defined is missing (use "Library=name" or "dll=name.dll" annotation).

Highlighting of source code sections seems not to work for PDF

I noticed that highlighted source code lines will not appear highlighted in the generated LaTeX/PDF version. I looked at the writer/latex.py from Sphinx where this functionality is actually present as of version 1.2.

So something to look into at some point.

Leaderboard for Contributors

I'd like to encourage people to contribute pull requests to make the book better. But at the same time, I want to give them credit for their contributions. A pull request isn't sufficient to earn "co-author" status but I'm thinking it would be nice to have some kind of "leaderboard" that is part of the acknowledgments directly in the book. I'm thinking it might be possible to use the GitHub API to actually extract and quantify people's contributions and then order them accordingly in the book.

First feedback on examples

Hi here follows my feed back on the examples you added so far (d02fefa):

  • NewtonCooling*: It is confusing why this cooling example actually shows a rising temperature behaviour. Wouldn't it be better to have a model where the ambient temperature is actually less than the initial temperature? (also present in all other variants of NewtonCooling
  • Backlash: Typo: behavior --> behaviour
  • StateSpace: Not clear why only ABCD is defined as partial but not the other. Maybe you plan to explain this in the book.
  • VectorTables: Don't use class as that should not really be used my modellers in any library. MSL also tries to get rid of it.

That's it for now. Got to run. I looked also through the rest. The component based parts are a bit more difficult to check without probably talking them through with you. I'm up for having a chat why you explain for what reason you've chosen that particular example. So I could give you feedback on that one too.

Consider adding start attributes to these models...

Model 71: ModelicaByExample.Functions.Interpolation.IntegrateInterpolatedVector
Warning In ModelicaByExample.Functions.Interpolation.IntegrateInterpolatedVector
There is no start attribute of state z. It is set to 0.
Model 75: ModelicaByExample.BasicEquations.SimpleExample.FirstOrderDocumented
Warning In ModelicaByExample.BasicEquations.SimpleExample.FirstOrderDocumented
There is no start attribute of state x. It is set to 0.
Model 76: ModelicaByExample.BasicEquations.SimpleExample.FirstOrder
Warning In ModelicaByExample.BasicEquations.SimpleExample.FirstOrder
There is no start attribute of state x. It is set to 0.

HierarchicalSystem_Variant1 missing sample_rate

Model 5: ModelicaByExample.Architectures.SensorComparison.Examples.HierarchicalSystem_Variant1
Information In sensor.sample_rate
The parameter sensor.sample_rate has no value. For simulation the value Modelica.Constants.eps from min attribute is used.

Long lines in Modelica examples

Some of the Modelica examples have very long lines in the source code. This is not to bad for the HTML version as there it is simply a matter of scrolling but in the PDF version those lines simply get cut off by the margin.

Scaled logo.png of sponsors on root-page.html

It is always a bad idea to down-scale the images in browser (by using the width attribute) as the resulting images often look poor. You better should use poperly scaled images instead, i.e. use with width=100%.

sponsors

Don't use MathJax when creating epub versions

I got an eReader for Christmas and started playing with the epub format of the book. This is when I noticed that MathJax (despite being part of the epub 3 format) it will not work properly (tested both in the calibre viewer and my device).

So we need to look into this one if epub format is something that should be offered. As a work around we can simply change conf.py by removing the line:

 'sphinx.ext.mathjax',

which basically means we fall back to dvipng graphics for equations.
Simply taking the PDF and converting this to epub using calibre will not work.

Investigate initial conditions in SwitchedRLC

Model 27: ModelicaByExample.Components.Electrical.Examples.SwitchedRLC
Warning In ModelicaByExample.Components.Electrical.Examples.SwitchedRLC
There is no start attribute of state capacitor.v. It is set to 0.
Warning In ModelicaByExample.Components.Electrical.Examples.SwitchedRLC
There is no start attribute of state inductor.p.i. It is set to 0.

Examples test run

I run the 77 example models I could identify in SimulationX Modelica simulator. Please find below the output (informationals, warnings and errors). Beside some obvious issues of the example models there are probably some issues in SimulationX as well.

Model 1: ModelicaByExample.Architectures.SensorComparison.Examples.BaseSystem
Model 2: ModelicaByExample.Architectures.SensorComparison.Examples.FlatSystem
Model 3: ModelicaByExample.Architectures.SensorComparison.Examples.FlatSystem_Variation1
Model 4: ModelicaByExample.Architectures.SensorComparison.Examples.HierarchicalSystem
Model 5: ModelicaByExample.Architectures.SensorComparison.Examples.HierarchicalSystem_Variant1
Information In sensor.sample_rate
The parameter sensor.sample_rate has no value. For simulation the value Modelica.Constants.eps from min attribute is used.
Model 6: ModelicaByExample.Architectures.SensorComparison.Examples.SystemArchitecture
Warning In ModelicaByExample.Architectures.SensorComparison.Examples.SystemArchitecture
The structure of the equation system is singular.Equations are missing.
Following equations are introduced:
sensor.shaft.tau=0.;
plant.housing.tau=0.;
plant.flange_a.tau=0.;
.
Model 7: ModelicaByExample.Architectures.SensorComparison.Examples.SystemArchitecture_WithDefaults
Model 8: ModelicaByExample.Architectures.SensorComparison.Examples.Variant1
Model 9: ModelicaByExample.Architectures.SensorComparison.Examples.Variant1_unstable
Model 10: ModelicaByExample.Architectures.SensorComparison.Examples.Variant2
Model 11: ModelicaByExample.Architectures.SensorComparison.Examples.Variant2_tuned
Model 12: ModelicaByExample.Architectures.ThermalControl.Examples.BaseModel
Model 13: ModelicaByExample.Architectures.ThermalControl.Examples.ExpandableModel
Model 14: ModelicaByExample.Architectures.ThermalControl.Examples.HysteresisVariant
Model 15: ModelicaByExample.Architectures.ThermalControl.Examples.OnOffVariant
Model 16: ModelicaByExample.ArrayEquations.StateSpace.Examples.FirstOrder
Model 17: ModelicaByExample.ArrayEquations.StateSpace.Examples.FirstOrder_Compact
Model 18: ModelicaByExample.ArrayEquations.StateSpace.Examples.LotkaVolterra
Warning In ModelicaByExample.ArrayEquations.StateSpace.Examples.LotkaVolterra
The structure of the equation system is singular.Equations are missing.
Following equations are introduced:
x_1_=0.;
x_0_=0.;
.
Calculation of consistent initial values failed! (Lotka-Volterra model in state space form)
Residuals out of the tolerance region       (used states and their derivatives):
initial equation 1         10.000000000000000   ()
initial equation 2         10.000000000000000   ()

Current Simulation Time:    0 s
Computation Time:   5.02250227662329e-005 s
Steps:  0
   Valid:       0
   Error:       0
   NoConv:      0
Calculations:
   Residuals:   2
   Jacobian:    0
   Dummy-pivotings: 0
   Event iterations:    1
Order:
   Changes:     0
   Max:         0
Matrix:
   Decomp:      0
   Solve:       0
   CodeGeneration:  0
Number of States:       0
Model 19: ModelicaByExample.ArrayEquations.StateSpace.Examples.NewtonCooling
Model 20: ModelicaByExample.ArrayEquations.StateSpace.Examples.RLC
Model 21: ModelicaByExample.ArrayEquations.StateSpace.Examples.RotationalSMD
Model 22: ModelicaByExample.ArrayEquations.StateSpace.Examples.RotationalSMD_Concat
Model 23: ModelicaByExample.Components.BlockDiagrams.Examples.ControlledCooling
Model 24: ModelicaByExample.Components.BlockDiagrams.Examples.MultiDomainControl
Warning In convection2.A
The parameter convection2.A has no value, 0 is assumed.
Model 25: ModelicaByExample.Components.BlockDiagrams.Examples.NewtonCooling
Model 26: ModelicaByExample.Components.ChemicalReactions.Examples.ABX_System
Model 27: ModelicaByExample.Components.Electrical.Examples.SwitchedRLC
Warning In ModelicaByExample.Components.Electrical.Examples.SwitchedRLC
There is no start attribute of state capacitor.v. It is set to 0.
Warning In ModelicaByExample.Components.Electrical.Examples.SwitchedRLC
There is no start attribute of state inductor.p.i. It is set to 0.
Model 28: ModelicaByExample.Components.HeatTransfer.Examples.Adiabatic
Model 29: ModelicaByExample.Components.HeatTransfer.Examples.ComplexNetwork
Model 30: ModelicaByExample.Components.HeatTransfer.Examples.Cooling
Model 31: ModelicaByExample.Components.HeatTransfer.Examples.CoolingToAmbient
Model 32: ModelicaByExample.Components.LotkaVolterra.Examples.ClassicLotkaVolterra
Model 33: ModelicaByExample.Components.LotkaVolterra.Examples.ThirdSpecies
Model 34: ModelicaByExample.Components.LotkaVolterra.Examples.ThreeSpecies_Quiescent
Error: Exception during the calculation. Reducing the minimal computation step size (dtMin) can solve the problem. (Three species in a quiescent state)
Error: Exception during the calculation
In Base type ModelicaByExample.Components.LotkaVolterra.Examples.ThirdSpecies of wolves: assert failed: Population must be greater than zero

Current Simulation Time:    0 s
Computation Time:   0.00668139445193135 s
Steps:  11
   Valid:       0
   Error:       0
   NoConv:      11
Calculations:
   Residuals:   87
   Jacobian:    20
   Dummy-pivotings: 1
   Event iterations:    1
Order:
   Changes:     1
   Max:         1
Matrix:
   Decomp:      14
   Solve:       67
   CodeGeneration:  2
Number of States:       3
Error
In Base type ModelicaByExample.Components.LotkaVolterra.Examples.ThirdSpecies of wolves: assert failed: Population must be greater than zero
Model 35: ModelicaByExample.Components.Rotational.Examples.SMD
Model 36: ModelicaByExample.Components.Rotational.Examples.SMD_ConfigurableGear
Model 37: ModelicaByExample.Components.Rotational.Examples.SMD_GearComparison
Model 38: ModelicaByExample.Components.Rotational.Examples.SMD_WithBacklash
Model 39: ModelicaByExample.Components.Rotational.Examples.SMD_WithGroundedGear
Model 40: ModelicaByExample.Components.SpeedMeasurement.Examples.Plant
Model 41: ModelicaByExample.Components.SpeedMeasurement.Examples.PlantWithIntervalMeasure
Model 42: ModelicaByExample.Components.SpeedMeasurement.Examples.PlantWithPulseCounter
Model 43: ModelicaByExample.Components.SpeedMeasurement.Examples.PlantWithSampleHold
Model 44: ModelicaByExample.PackageExamples.NewtonCooling
Model 45: ModelicaByExample.PackageExamples.RLC
Warning In ModelicaByExample.PackageExamples.RLC
There is no start attribute of state V. It is set to 0.
Warning In ModelicaByExample.PackageExamples.RLC
There is no start attribute of state i_L. It is set to 0.
Model 46: ModelicaByExample.PackageExamples.SecondOrderSystem
Model 47: ModelicaByExample.Subsystems.GearSubsystemModel.Examples.BacklashExample
Model 48: ModelicaByExample.Subsystems.GearSubsystemModel.Examples.FlatSystemWithBacklash
Model 49: ModelicaByExample.Subsystems.HeatTransfer.Examples.FlatRod
Model 50: ModelicaByExample.Subsystems.HeatTransfer.Examples.OneHundredSegmentRod
Model 51: ModelicaByExample.Subsystems.HeatTransfer.Examples.SegmentComparison
Model 52: ModelicaByExample.Subsystems.HeatTransfer.Examples.SixSegmentRod
Model 53: ModelicaByExample.Subsystems.HeatTransfer.Examples.TenSegmentRod
Model 54: ModelicaByExample.Subsystems.HeatTransfer.Examples.ThreeSegmentRod
Model 55: ModelicaByExample.Subsystems.HeatTransfer.Examples.TwoHundredSegmentRod
Model 56: ModelicaByExample.Subsystems.LotkaVolterra.Examples.InitiallyDifferent
Model 57: ModelicaByExample.Subsystems.LotkaVolterra.Examples.UnconnectedPopulations
Model 58: ModelicaByExample.Subsystems.LotkaVolterra.Examples.WithMigration
Model 59: ModelicaByExample.Subsystems.Pendula.Pendulum
Warning In ball
The declaration of world (inner) is missing and automatically created.
No "world" component is defined. A default world
component with the default gravity field will be used
(g=9.81 in negative y-axis). If this is not desired,
drag Modelica.Mechanics.MultiBody.World into the top level of your model.
Warning In L
The parameter L has no value, 0 is assumed.
Information In m
The parameter m has no value. For simulation the value 0 from min attribute is used.
Warning In phi
The parameter phi has no value, 0 is assumed.
Warning In x
The parameter x has no value, 0 is assumed.
Warning In ModelicaByExample.Subsystems.Pendula.Pendulum
The structure of the equation system is singular.Equations are missing.
_der_revolute.w:
| _der_revolute.phi --> der-Equation of _der_revolute.phi and _der_revolute.w
| | string.body.w_a_2_ --> string.body.w_a_2_=-_der_revolute.phi;
| | | _der_string.body.w_a_2_ --> der-Equation of string.body.w_a_2_ and _der_string.body.w_a_2_
| | revolute.phi --> der-Equation of revolute.phi and _der_revolute.phi
| | | revolute.R_rel.T_4_ --> revolute.R_rel.T_4_=cos(revolute.phi);
| | | | revolute.frame_a.R.T_4_ --> revolute.frame_a.R.T_4_=revolute.R_rel.T_4_* ground.frame_b.R.T[2,2];
| | | revolute.R_rel.T_3_ --> revolute.R_rel.T_3_=sin(revolute.phi);
| | | | revolute.frame_a.R.T_3_ --> revolute.frame_a.R.T_3_=revolute.R_rel.T_3_* ground.frame_b.R.T[1,1];
| | | revolute.R_rel.T_1_ --> revolute.R_rel.T_1_=-1*sin(revolute.phi);
| | | | revolute.frame_a.R.T_1_ --> revolute.frame_a.R.T_1_=revolute.R_rel.T_1_* ground.frame_b.R.T[2,2];
| | | revolute.R_rel.T_0_ --> revolute.R_rel.T_0_=cos(revolute.phi);
| | | | revolute.frame_a.R.T_0_ --> revolute.frame_a.R.T_0_=revolute.R_rel.T_0_* ground.frame_b.R.T[1,1];
.
Error: Exception during the calculation. Reducing the minimal computation step size (dtMin) can solve the problem. (A single individual pendulum)
Error: Exception during the calculation
In Modelica.Math.Vectors.normalizeWithAssert: assert failed: Vector v={0,0,0} shall be normalized (= v/sqrt(v*v)), but this results in a division by zero.
Provide a non-zero vector!

Current Simulation Time:    0 s
Computation Time:   0.00277704049236653 s
Steps:  2
   Valid:       1
   Error:       0
   NoConv:      1
Calculations:
   Residuals:   4
   Jacobian:    0
   Dummy-pivotings: 0
   Event iterations:    1
Order:
   Changes:     0
   Max:         0
Matrix:
   Decomp:      0
   Solve:       0
   CodeGeneration:  0
Number of States:       0
Error
In Modelica.Math.Vectors.normalizeWithAssert: assert failed: Vector v={0,0,0} shall be normalized (= v/sqrt(v*v)), but this results in a division by zero.
Provide a non-zero vector!
Model 60: ModelicaByExample.Subsystems.Pendula.System
Error In Modelica.Math.Vectors.normalizeWithAssert
_2_Modelica.Math.Vectors.normalizeWithAssert.result:=
                                                     pendulum.revolute.n*sqrt(pendulum.revolute.n*pendulum.revolute.n)^-1;
In an assignment, the variable ([15]-vector) must have the same dimension as the expression ([3]-vector).
Error In pendulum.revolute.cylinder.r_shape
pendulum.revolute.cylinder.r_shapeCalc=
                                       -1*_2_Modelica.Math.Vectors.normalizeWithAssert.result*pendulum.revolute.cylinderLength*0.5;
In an equation, the left ([3]-vector) and the right side ([15]-vector) must have the same dimension.
Error In pendulum.revolute
pendulum.revolute.tau=
                      -1*pendulum.revolute.frame_b.t*_2_Modelica.Math.Vectors.normalizeWithAssert.result;
The operator "*" requires arguments of equal dimensions.
Error In Modelica.Math.Vectors.normalizeWithAssert
_3_Modelica.Math.Vectors.normalizeWithAssert.result:=
                                                     pendulum.string.lengthDirection*sqrt(pendulum.string.lengthDirection*pendulum.string.lengthDirection)^-1;
In an assignment, the variable ([15]-vector) must have the same dimension as the expression ([3]-vector).
Error In pendulum.string.r_CM
pendulum.string.r_CM=pendulum.string.r_shape+_3_Modelica.Math.Vectors.normalizeWithAssert.result*pendulum.string.length*0.5;
The operator "+" requires arguments of equal dimensions.
Error In pendulum.string.sequence_angleStates.min
pendulum.string.sequence_angleStates.min:=
                                          {1,1,1};
In an assignment, the variable ([15,3]-matrix) must have the same dimension as the expression ([3]-vector).
Error In pendulum.string.sequence_angleStates.max
pendulum.string.sequence_angleStates.max:=
                                          {3,3,3};
In an assignment, the variable ([15,3]-matrix) must have the same dimension as the expression ([3]-vector).
Error In pendulum.string.sequence_start.min
pendulum.string.sequence_start.min:=
                                    {1,1,1};
In an assignment, the variable ([15,3]-matrix) must have the same dimension as the expression ([3]-vector).
Error In pendulum.string.sequence_start.max
pendulum.string.sequence_start.max:=
                                    {3,3,3};
In an assignment, the variable ([15,3]-matrix) must have the same dimension as the expression ([3]-vector).
Error In pendulum.string.body.sequence_angleStates.min
pendulum.string.body.sequence_angleStates.min:=
                                               {1,1,1};
In an assignment, the variable ([15,3]-matrix) must have the same dimension as the expression ([3]-vector).
Error In pendulum.string.body.sequence_angleStates.max
pendulum.string.body.sequence_angleStates.max:=
                                               {3,3,3};
In an assignment, the variable ([15,3]-matrix) must have the same dimension as the expression ([3]-vector).
Error In pendulum.string.body.sequence_start.min
pendulum.string.body.sequence_start.min:=
                                         {1,1,1};
In an assignment, the variable ([15,3]-matrix) must have the same dimension as the expression ([3]-vector).
Error In pendulum.string.body.sequence_start.max
pendulum.string.body.sequence_start.max:=
                                         {3,3,3};
In an assignment, the variable ([15,3]-matrix) must have the same dimension as the expression ([3]-vector).
Model 61: ModelicaByExample.Subsystems.PowerSupply.Examples.AdditionalLoad
Model 62: ModelicaByExample.Subsystems.PowerSupply.Examples.FlatCircuit
Model 63: ModelicaByExample.Subsystems.PowerSupply.Examples.SubsystemCircuit
Model 64: ModelicaByExample.Functions.Polynomials.Differentiation1
Model 65: ModelicaByExample.Functions.Polynomials.Differentiation2
Model 66: ModelicaByExample.Functions.Polynomials.EvaluationTest1
Model 67: ModelicaByExample.Functions.Nonlinearities.ExplicitEvaluation
Model 68: ModelicaByExample.Functions.ImpureFunctions.HysteresisEmbeddedControl
Error In ModelicaByExample.Functions.ImpureFunctions.HysteresisEmbeddedControl
Q=computeHeat(T,Tbar,Qcapacity);
^---

Unknown function "computeHeat" referenced.
Model 69: ModelicaByExample.Functions.Nonlinearities.ImplicitEvaluation
Model 70: ModelicaByExample.Functions.Interpolation.IntegrateInterpolatedExternalVector
Warning In ModelicaByExample.Functions.Interpolation.IntegrateInterpolatedExternalVector
There is no start attribute of state z. It is set to 0.
The name of the library is missing.
In ModelicaByExample.Functions.Interpolation.VectorTable: The name of the library where the external function createVectorTable is defined is missing (use "Library=name" or "dll=name.dll" annotation).
Model 71: ModelicaByExample.Functions.Interpolation.IntegrateInterpolatedVector
Warning In ModelicaByExample.Functions.Interpolation.IntegrateInterpolatedVector
There is no start attribute of state z. It is set to 0.
Model 72: ModelicaByExample.BasicEquations.SimpleExample.FirstOrderSteady
Model 73: ModelicaByExample.BasicEquations.SimpleExample.FirstOrderInitial
Model 74: ModelicaByExample.BasicEquations.SimpleExample.FirstOrderExperiment
Model 75: ModelicaByExample.BasicEquations.SimpleExample.FirstOrderDocumented
Warning In ModelicaByExample.BasicEquations.SimpleExample.FirstOrderDocumented
There is no start attribute of state x. It is set to 0.
Model 76: ModelicaByExample.BasicEquations.SimpleExample.FirstOrder
Warning In ModelicaByExample.BasicEquations.SimpleExample.FirstOrder
There is no start attribute of state x. It is set to 0.
Model 77: ModelicaByExample.BasicEquations.CoolingExample.NewtonCoolingWithDefaults

I need to check what happens with the Pendula models.

Split examples package into a separate repository

I'm thinking it would make sense to split the examples library out into a separate repository and then make it either a submodule or subtree of this respository (not sure which makes sense). This would have a couple of benefits:

  1. It would allow people to reference the ModelicaByExample package from impact.
  2. It would keep "tickets" for the models separate from things related to the book.

Plotting

For plots, I'd like to add some Javascript to allow for an interactive plotting interface. I don't think I'll have the time for that in the near term. But what I need to remember to do is have the scripts that generate static plots also generate some JSON (?) that contains the data I want to plot (in some kind of namespace) so that when/if I do want to plug in some kind of Javascript, I can be sure I'll have the actual data it needs as well.

Links to Modelica Spec and MSL

It would be nice if there were canonical ways to link to both the Modelica Standard Library and the Modelica Specification. It might be a nice idea for the Modelica Association to setup a system whereby the following links redirected to the correct places:

http://docs.modelica.org/spec?section=12.7&version=3.2 (Section 12.7 of the 32. spec)

http://docs.modelica.org/msl/Modelica/Blocks (Link to the documentation for "Modelica.Blocks")

It would be easy to do and it would make it so easy to reference things.

ModelicaByExample.Architectures.ThermalControl.Implementations.*

ModelicaByExample.Architectures.ThermalControl.Implementations.ConventionalOnOffControl is missing, but uses, a parameter "setpoint". It also does not set the output "heat" defined in it's superclass, Interfaces.ControlSystem.

ModelicaByExample.Architectures.ThermalControl.Implementations.ConventionOnOffActuator does not appear to utilise the input declared in Interfaces.Actuator.

Icons in PDF

I found this link that indicates you should compile all SVG files into PDF files using Inkscape. Then you should link to them in the source as:

.. image:: path/to/image/ImageName.*

where each builder will apparently pick up the image it thinks will work the best (SVG for HTML and PDF for LaTeX, it appears).

Wrong statement about unit default

In http://beta.book.xogeny.com/behavior/equations/variables/, you state that the default for unit is "1". This is not true: the spec says the default is "", and rightly so, because saying dimensionless is different than saying unspecified dimension. If the default was "1", then this model would be wrong

Real m;
Force F;
Acceleration a;
equation
F = ma;

while it is actually ok, and the meaning of the default "" is that the compiler can actually infer that the unit of m is "kg". BTW, I would explain the meaning of unit="" explicitly in the text, and point out this difference.

iOS compatibility

I found that the value for TOTAL_MEMORY in generated .js files is huge. For an iOS device, there is a limit (somewhere between 200Mb and 400Mb) for how much memory it can allocate for an array. This is causing problems for both iPhone and iPad.

Lowering the value is possible. Although it isn't clear how low it can go. But the emscripten documention mentions an option called ALLOW_MEMORY_GROWTH which we should try. There is some performance degradation, but I'd rather have a little bit of performance degradation vs. not running at all.

HysteresisEmbeddedControl issue with computeHeat function

Model 68: ModelicaByExample.Functions.ImpureFunctions.HysteresisEmbeddedControl
Error In ModelicaByExample.Functions.ImpureFunctions.HysteresisEmbeddedControl
Q=computeHeat(T,Tbar,Qcapacity);
^---

Unknown function "computeHeat" referenced.

Fix eventListener for simulations

The logic for a worker involves a complex set of messages. There is a block of code in xogeny.js that gets run if the data has already been loaded. But it should return in that case (or include an else clause).

Need synchronous examples

I need to add some examples that use the synchronous features in Modelica.

My guess is that these will have to go in the mathematic behavior part under discrete behavior. But I need to think of an example that would fit there.

Annotation folding

I should find or create a script that will do annotation folding in the HTML listings. If people don't have Javascript, then they just don't get the folding feature. But if they do, then they should have some way to expand or collapse annotations (with the default being collapsed except possibly in sections where annotations are being specifically discussed).

Error in Lotka-Volterra Equations

Reported by Kai Wang:

Mike,

I found a typo in the section of Lotka-Volterra. In the following equations, x_dot_s should be y_dot_s. Just for your information.

\dot{x} &= \dot{x}_r + \dot{x}_p
\dot{y} &= \dot{y}_p + \dot{x}_s

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.