modelica / ModelicaStandardLibrary

Free (standard conforming) library to model mechanical (1D/3D), electrical (analog, digital, machines), magnetic, thermal, fluid, control systems and hierarchical state machines. Also numerical functions and functions for strings, files and streams are included.
https://doc.modelica.org
BSD 3-Clause "New" or "Revised" License
472 stars 168 forks source link

Enhance unit deduction functionality by adding 'unit="1"' to some blocks #227

Closed modelica-trac-importer closed 7 years ago

modelica-trac-importer commented 7 years ago

Reported by dietmarw on 26 Oct 2009 12:15 UTC Some time ago I was presented with a simple example model where apparently the unit deduction didn't work as expected in Dymola. The Dynasim people quickly presented me with a way how unit deduction can also be made to work in this case (see attached UnitDeductTest.zip). So all what was missing was to tell the tool that the unit of the (in this case) gain was "1".

In the attached model, for example the integral of the current is calculated and the gain of the integrator is defined as:

 parameter Real k=1 "Integrator gain";

the resultant output signal will be unitless (see AsUnitless.y). But if one changes the gain to the following:

 parameter Real(unit="1") k=1 "Integrator gain";

(as done in Asec) the resulting signal will have the correct unit 'C'(='A.s').

Looking at the MSL I found several places (especially Multibody) where already unit="1" was added as parameter modifier.

So wouldn'd it be a good idea to add this change to blocks like:

Modelica.Blocks.Continous.{Integrator|LimIntegrator|Deriative|FirstOrder|Secondorder|PI|PID|LimPID} 

and maybe others. Or are there any drawbacks to such a change?


Migrated-From: https://trac.modelica.org/Modelica/ticket/227

modelica-trac-importer commented 7 years ago

Comment by otter on 16 Jul 2010 07:19 UTC Fixed in af01213debfd82ab3e16d76346673466b4c6925b (all scalar gains in blocks of the Modelica.Blocks library have now a unit="1" definition. Also a test model for this is provided in ModelicaTest)

modelica-trac-importer commented 7 years ago

Modified by dietmarw on 16 Jul 2010 07:54 UTC