Changeset 714

Show
Ignore:
Timestamp:
10/17/2007 08:10:59 AM (15 months ago)
Author:
otter
Message:

New section "Parameter defaults" in Modelica.UsersGuide according to the email discussion

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • Modelica/trunk/Modelica/package.mo

    r695 r714  
    541541  end Conventions; 
    542542   
     543  class ParameterDefaults "Parameter defaults"  
     544     
     545    annotation (Documentation(info="<html> 
     546 
     547<p> 
     548In this section the convention is summarized how default parameters are 
     549handled in the Modelica Standard Library (since version 3.0). 
     550</p> 
     551 
     552<p> 
     553Many models in this library have parameter declarations to define 
     554constants of a model that might be changed before simulation starts. 
     555Example: 
     556</p> 
     557 
     558<blockquote> 
     559<pre> 
     560<b>model</b> SpringDamper 
     561   <b>parameter</b> Real c(final unit=\"N.m/rad\")    = 1e5 \"Spring constant\"; 
     562   <b>parameter</b> Real d(final unit=\"N.m.s/rad\")  = 0   \"Damping constant\"; 
     563   <b>parameter</b> Modelica.SIunits.Angle phi_rel0 = 0   \"Unstretched spring angle\"; 
     564   ... 
     565<b>end</b> SpringDamper; 
     566</pre> 
     567</blockquote> 
     568 
     569<p> 
     570In Modelica it is possible to define a default value of a parameter in 
     571the parameter declaration. In the example above, this is performed for 
     572all parameters. Providing default values for all parameters can lead to 
     573errors that are difficult to detect, since a modeler may have forgotten 
     574to provide a meaningful value (the model simulates but gives wrong 
     575results due to wrong parameter values). In general the following basic 
     576situations are present: 
     577</p> 
     578 
     579<ol> 
     580<li> The parameter value could be anything (e.g., a spring constant or 
     581     a resistance value) and therefore the user should provide a value in 
     582     all cases. A Modelica translator should warn, if no value is provided. 
     583     <br><br></li> 
     584 
     585<li> The parameter value is not changed in &gt; 95 % of the cases 
     586     (e.g. initialization or visualization parameters, or parameter phi_rel0 
     587     in the example above). In this case a default parameter value should be 
     588     provided, in order that the model or function can be conveniently 
     589     used by a modeler. 
     590     <br><br></li> 
     591 
     592<li> A modeler would like to quickly utilize a model, e.g., 
     593     <ul> 
     594     <li> to automatically check that the model still translates and/or simulates 
     595          (after some changes in the library),</li> 
     596     <li> to make a quick demo of a library by drag-and-drop of components,</li> 
     597     <li> to implement a simple test model in order to get a better understanding 
     598          of the desired component.</li> 
     599     </ul> 
     600     In all these cases, it would be not practical, if the modeler would 
     601     have to provide explicit values for all parameters first. 
     602     </li> 
     603</ol> 
     604 
     605<p> 
     606To handle the conflicting goals of (1) and (3), the Modelica Standard Library 
     607uses two approaches to define default parameters, as demonstrated with the 
     608following example: 
     609</p> 
     610 
     611<blockquote> 
     612<pre> 
     613<b>model</b> SpringDamper 
     614   <b>parameter</b> Real c(final unit=\"N.m/rad\"  , start=1e5) \"Spring constant\"; 
     615   <b>parameter</b> Real d(final unit=\"N.m.s/rad\", start=  0) \"Damping constant\"; 
     616   <b>parameter</b> Modelica.SIunits.Angle phi_rel0 = 0       \"Unstretched spring angle\"; 
     617   ... 
     618<b>end</b> SpringDamper; 
     619 
     620SpringDamper sp1;              // warning for \"c\" and \"d\" 
     621SpringDamper sp2(c=1e4, d=0);  // fine, no warning 
     622</pre> 
     623</blockquote> 
     624 
     625<p> 
     626Both definition forms, using a \"start\" value (for \"c\" and \"d\") and providing 
     627a declaration equation (for \"phi_rel0\"), are valid Modelica and define the value 
     628of the parameter. By convention, it is expected that Modelica translators will 
     629trigger a warning message for parameters that are <b>not</b> defined by a declaration 
     630equation, by a modifier equation or in an initial equation/algorithm section.  
     631A Modelica translator might have options to change this behavior, especially, 
     632that no messages are printed in such cases and/or that an error is triggered 
     633instead of a warning. 
     634</p> 
     635 
     636</html> 
     637")); 
     638  end ParameterDefaults; 
     639 
    543640  package ReleaseNotes "Release notes"  
    544641