Home
AMESet User Manual
Contents
1. port 1 extemal variable 1 Variable generalities Type of variable basic variable Input output status output Varable can be plotted True SPR ULDA o wv spring l Change icon Brief description ideal linear spring no states E l Forts o Fort1 extemal variables 3 lzhaft z External variable 1 al Variable details External variable 2 hd Title force at port 1 Unit M C Variable name force Dimension 1 Submodel requirements Submodel requires time Submodel requires discontinuities flag Convert unit ta 51 Call ta the calculation Function f Always C Never C when printing Setting the basic features of a submodel Setting Changing the submodel icon 168 When you start creating a new submodel specification you can either select an icon in one of the available categories this icon is then assigned to the submodel you are dealing with as in Figure 5 18 AMESet 4 2 User Manual Figure 5 18 All submodels must be associated with an icon E spring or w you can use the menu File f New or Ctrl N or click on and no icon is assigned to your submodel for the time being as shown in Figure 5 19 Figure 5 19 For New there is initially no icon Ho icon specified Change icon In both cases you can click on the button Change icon in order to replace the icon currently assigned to the submod
2. Lt ey gt 0 0 xv coefr v j The state has changed and must be reset cond 1 j if disimp amp cond amp ic 01 ydot XV vdot Step 9 Compile your submodel Be careful of any left over code from BL50 For instance any references to the old variable mass must be removed Step 10 Use your new submodel in AMESim It cannot be connected to the old floor submodels Connect it instead to the general signal stopper With the default parameters run a simulation and plot a graph of displacement of ball You will find all is well for a 10s run but if you increase the final time to 20s and enable discontinuity the situation is very different If you do this be ready with the stop button AMESet 4 2 User Manual Figure 4 53 The ball does not stop bouncing A 1 BLE1 1 displacement of ball m O 2 4 5 Z 10 12 14 Time s Figure 4 54 The discontinuities get ever closer ELS1 instance 1 discontinuity at Time 12 8506 ELS1 instance 1 discontinuity at Time 12 8506 ELS1 instance 1 discontinuity at Time 12 8506 ELS1 instance 1 discontinuity at Time 12 8506 ELS1 instance 1 discontinuity at Time 12 8506 ELS1 instance 1 discontinuity at Time 12 8506 ELS1 instance 1 discontinuity at Time 12 8506 Note how the discontinuity handling picks out very sharply the instantaneous changes in the velocity Figure 4 55 Instantaneous changes in velocity 1 BL51 1 velocity of ball m s
3. Windows menu This comprises permanent items Windows Help Cascade mL Cascade Close all m hsubmodels PM50 spe An extra item is added for each open submodel Close all specification You can bring an open submodel specification to the top 1 e make it the active submodel by selecting it Cascade Windows gt Cascade arranges the windows corresponding to each open submodel so that each is visible but they overlap Close all Windows P Close all initiates the process of closing all the open submodel specification If there are unsaved changes you will be asked if you want to save them Help menu Help OnLine 2 About OnLine Use Help PF OnLine to view documentation of AMESim submodels These may be in libraries supplied as an AMESim product submodels produced by you or by a colleague Referring to Figure 5 3 on the left side of the screen you can find three tabs 163 Chapter 5 Reference Guide for AMESet Contents which shows the list of the documentation topics e Index from which you can type in a keyword and get the related entries Search from which you can get the list of all the documents containing at least one occurrence of a given keyword Figure 5 12 On line Help aA Help AMESim on line documentation File Go Display Bookmarks Libraries E Qe AMECUstom E m Demo Applications amp Demo Libraries QL ibraries he i Manuals Mechanical
4. Brief description prime mover with startup characteristics EE ical parameters i Integer parameters i i Text parameters 0 Integer shores QD Submodel requirement e Submodel requires time I Submodel requires discontinuities flag Convert unit ta SI Call to the calculation function v Always C Never C when printing When you have done this save this new version as PM31 You can then generate F77 or C code without any further modification 59 Chapter 3 Getting Started 60 In F77 subroutine pm51 n omega rp ic flag t integer n ic 1 double precision rp 3 omega double precision t tau tstart integer flag logical logi logical disimp external disloc disimp external distim C gt gt gt gt gt gt gt gt gt gt gt gt Extra Calculation Function Declarations Here C lt lt lt lt lt lt lt lt lt lt lt lt End of Extra Calculation declarations omegaf rp 1 Estart xp tau xpo C Set all submodel outputs below C omega 22 C gt gt gt gt gt gt gt gt gt gt gt gt Calculation Function Executable Statements if t ge tstart then omega omegaf 1 exp t tstart tau else omega 0 0 endif C lt lt lt lt lt lt lt lt lt lt lt lt End of Calculation Executable Statements end In C AMESet 4 2 User Manual ifdef NO PROTO void pm51_ n omega rp ic flag t int n double omega
5. Sometimes submodels require time as an input Usually they can be described as duty cycle submodels They provide an output variable which is a prescribed function of time The current value of time is provided by the integration algorithm and is updated as the simulation progresses Not all duty cycle submodels require time as an input One could use another variable on which to base the duty cycle 2 19 Real integer and text parameters The size of components has to be defined The characteristics of duty cycles have to be set You perform these tasks when you set submodel parameters AMESim sets default parameters when a submodel is selected and you can accept the defaults or change them as you want These parameters can be real quantities integer quantities or text expressions being known as real parameters integer parameters and text parameters respectively In computing terms they are supplied to a submodel as arrays They are optional and can be omitted if not required The need for the real parameters is obvious Integer parameters are normally used for specifying which of several modes is selected For example many hydraulic submodels include an orifice There are two ways that AMESim uses to specify the flow characteristics of a submodel 1 the user sets an orifice diameter and flow coefficient and these together with the fluid density determine the flow 11 a flow rate and corresponding pressure drop pair are set and
6. Tvpe of variableexplicit state Title shaft speed port Z Unit rev min Variable name Ww Variable derivative name wdot Dimension 1 Minimum expected initial value 10000 Default initial value O Maximum expected initial value 10000 On port the first external variable is a duplicate variable Figure 4 58 External variable is a duplicate external variable 1 Type of variableduplicate variable Duplicate type sign reversed c Primary port number 2 Primary variable number 1 Note that it must be specified State variable Duplicate variable what it is a duplicate of It is a em t an li f th state variable 113 Chapter 4 Advanced examples 114 Duplicate variables come in two types simple and Value reversed sign The rotary speed is a quantity which has a 3 duplicate variable direction associated with it With the AMESim sign sign reversed convention if the state variable on port 2 1s 2000 rev min the variable on port 1 is 2000 rev min This duplicate sign reversed variable is reversed sign Note With duplicates of variables that have a direction associated with them the type will be reversed sign Other examples are mass flow rate volumetric flow rate displacement acceleration force torque With duplicates of variables that have no direction associated with them they will be of type simple Examples are pressure volume mass etc Step 4 Without changing anything generate
7. tria External variables Update categories Available user submodels y The selected object is removed The shortcut is Ctrl X The facility is also available by clicking on the Cut current item button in the toolbar AMESet 4 2 User Manual Copy The selected object is copied into a special buffer or clipboard The shortcut is Ctrl C The facility is also available by clicking on the Copy current item button in the tool bar Paste The contents of the selected object are overwritten with the contents of the clipboard The shortcut is Ctrl V The facility is also available by clicking on the Paste current item button in the tool bar Move up If it is possible the selected object is moved up one position in the list The shortcut is Ctrl Up Remember that with external variables the rule e outputs first inputs next e inputs with default last is strictly enforced Move down If it is possible the selected object is moved down one position in the list The shortcut is Ctrl Down Remember that with external variables the rule e outputs first inputs next inputs with default last is strictly enforced The next three items operate A Find Chee on the source code displayed 7 in the fallback editor Hopee zur Go to Chri G Find E Find Ea Use Edit Find to look for text in the code editor You Pira ost variable x can also use the short cut Match whole word only irecti Cntrl
8. Introduction This chapter shows you how to create your own AMESim submodels and icons by presenting a series of tutorial examples However before attempting to read this chapter and doing the tutorial exercises you should have experience at using AMESim performing simple simulations using the standard AMESim submodel libraries You should also read Chapter 2 which gives a general background on AMESim submodels The time taken to perform these tutorial exercises varies enormously They are open ended in the sense that you can make your own minor modifications to the submodels and to the experiments performed on them but allow at least three hours to do a thorough job Creating an AMESim submodel involves constructing some code This can be done in either Fortran 77 which will be referred to as F77 or C However do not allow this to intimidate you Much of the code can be generated automatically after which you insert a relatively small number of lines of code Note that there are a lot of sections of code which have been inserted in this chapter They are similar to that which is generated by AMESet but the code has been shortened slightly by removing some comments The final version of each of the submodels described in this chapter is stored in the following directory Using Unix SAME tutorial submodels Using Windows AME tutoriallsubmodels You can of course copy these files into your own submodels area However it is
9. else omega 0 0 Register discontinuity at time tstart distim amp tstart lt lt lt lt lt lt lt lt lt lt lt lt End of Calculation Executable Statements At this point a few words of explanation are needed Set the value of ic 0 d Calls are made to the calculation routine with integer flag set to a variety of values The value indicates the purpose of the call The only special value you need worry about is flag 0 This is a call to the routine for the purpose of initialization At the start of each run the first call to each submodel which has a discontinuity will have flag 0 If any discontinuity occurs during a run immediately after the discontinuity is located there will be a further call to each submodel with flag 0 This allows the submodel to perform any initialization 64 AMESet 4 2 User Manual For the current submodel ic 1 in F77 or ic 0 1n C is set to 0 if the prime mover is in the pre start up phase or 1 otherwise There are now two sections of code corresponding to each of the two values of the ic state indicator For each call to the submodel only one section of code will be visited A switch from one section of code to the other corresponds to a discontinuity In this case it is possible to switch from the pre start up to the post start up phase but impossible to switch in the other direction The Fortran subroutine distim or the C function distim_
10. gt y0 cond2 condl The function disimp 1s then used as follows if disimp amp cond1l amp ic 0 Object is in contact with floor fext k y yO damp v j else if disimp amp cond2 amp ic 1 Object is free of floor fext 0 Knowledge of the full details of what happens within disimp is unnecessary However you may find the following outline of the main stages useful At the start of the integration there is a special call and one of ic 1 ic 2 will be set This means one of the two possibilities is enabled After this the possibility selected will be used in calls to the submodel It may be that at some stage the logical condition of the selected branch becomes false If this happens the integrator will interpolate backwards looking for the time at which the discontinuity occurs Eventually the discontinuity will be located as accurately as possible Two times will be found which are very very close together one of which makes the condition true and the other false In the code of the integrator these are referred to as tl and tr with tl lt tr The integrator then shuts down and restarts as if it where a completely new run with initial time tr The values of the state and implicit values at the time tr are used as starting values e The first call to the submodels after the restart will be an initialization call just like at the start of the integration This will interch
11. if there are subtle differences the C code 1s also presented However note that all submodels in the AMESim libraries are written in C A powerful facility in AMESet is that you can load a standard AMESim submodel modify it in some way and save it locally under a different name To use this facility you have to work in C We also illustrate the sort process used in AMESim by showing code generated by AMESim This is always in C Bouncing ball The object of this exercise is to construct some submodels which have a number of interesting discontinuities This is one feature that must be treated carefully in AMESim and you will probably require a little practice before you master the process Another subject of interest 1s the activity variables that we will also introduce in this chapter In Chapter 3 there were two examples with a discontinuity which occurred at a known time In practice AMESim goes past the discontinuity and then effectively interpolates back to find the values of the state and implicit variables at the known discontinuity time In other situations it is more difficult because although it is easy to detect that AMESim has gone past the discontinuity the time at which the discontinuity occurred is not known by the submodel and hence distim cannot be used 75 Chapter 4 Advanced examples 76 It is worth stressing at this stage the following points The AMESim integrator does not detect discontinuities e It
12. 3S 4 10 Help Neni zo oos o ERA Sr See e Re oe enu RP PEE 163 59 The A MESet toolbars toria hw Redde o eR eo een 166 5 6 The AMESet main window 0 00 ccc cee eee eee 167 5 6 1 Setting the basic features of a submodel o ooooo 168 Setting Changing the submodel icon 006 168 Setting a brief description cc cee ee 170 Right click menus associated with ports variables and parameters 170 xr sch is ane oe eG ten ae Gane Bk Soe ec eae ee ace he 171 Table of contents Inserts a DOE od ean ed eRe oe a de nde 171 Editing the number of ports 0 0 cece 12 REMOVE APO cap teed toU d neg ace S PSP 172 Movme apor os qoe re CRAT d op ERR 173 SENE POR TVDOS o oon Pa a RE ene Sext orae A 173 Declaring external variableS oooooooooooooo 173 Declaring internal variableS ooooooooooooo 174 Declaring real integer text parameters o o ooooooooo 174 Declaring integer real stores sk A ee ee 174 Setting the submodel requirements o oooooooooooo 175 5 6 2 Setting the characteristics of variables and parameters 175 Setting the characteristics of an external variable 176 Setting the characteristics of an internal variable 178 Setting the characteristics of a real parameter 180 Setting the characteristics of an integer parameter 181 Setting the characteristic
13. Ball has hit the floor 0 080 then If bounce velocity is very small reset it to zero if v le vtol then Ball has stopped bouncing v 0 0d0 ic 2 1 endif endif endif endif if ic 2 eq O then C C Ball is bouncing C if disimp y le y0 ic 1 then C C Ball is still falling freely C ydot vdot endif else Ball has stopped bouncing ydot 0 0dqd0 vdot 0 0d0 endif This involves an extra real parameter with name vtol introduced into BL51 This is set to a small value e g 1 0e 6 and is used to stop the bounce and also a second integer store ic 2 Note that in this code ic 2 is not initialized to 0 This initialization can be done in 108 4 2 8 AMESet 4 2 User Manual executable code section of the initialization routine The bouncing ball is a rich source of interesting modeling problems An obvious extension of the model is to make the motion two dimensional introducing a horizontal displacement x and velocity u You can then have two walls introducing a bounce in the horizontal direction If you have time you can develop this model and simulate a game of squash Use of disloc So far you have used the discontinuity handling functions distim and disimp For more than 95 of submodels with discontinuities these will provide all the functionality necessary However there is a third discontinuity function disloc This does much the same as disimp but many features which are automat
14. C Living dangerously No discontinuity handling C 88 AMESet 4 2 User Manual if y ge yO then The object is in contact with the floor C fext k y yO damp v else C C The object is free of the floor C fext 0 0dqd0 endif endif In C if mode 1 Full discontinuity handling selected Gong y gt y0 cond2 condl if disimp amp condl amp ic 0 The object in contact with the floor fext k y yO damp v j else 1f disimp amp cond2 amp ic 1 The object is free of the floor xfext 0 0 j j else Living dangerously No discontinuity handling if y gt y0 The object in contact with the floor fext k y yO damp v j else The object is free of the floor xfext 0 0 Step 6 Compile the code If necessary make corrections to any errors detected by the compiler Step 7 Start AMESim and connect the ball icon to the floor icon The submodels should be selected automatically Run several simulations with run statistics enabled with and without discontinuity handling in FL50 You will 89 Chapter 4 Advanced examples probably find that for most but by no means all sets of parameters the runs are slightly faster with discontinuity handling If you enable extra printout at discontinuity points you will find the points at which the ball contacts and leaves the floor is lo
15. F Enter the text you Bl rinse are looking for and then click on Find next Lose 141 Chapter 5 Reference Guide for AMESet 142 Replace Bi Find amp Replace i ES Use Edit gt Replace or the short cut Cntrl H to replace Find what fydot I occurrences of one text string Replace with 1 dot in the code editor by another Bill lene whale cda if Replace Fill the text strings in the Find amp Replace elo box Match case Replace All Close Go to Elo To Use Edit gt Go to or the short cut Cntrl G to scroll the Go ta line No 100 S code editor to a specified line Fill the line number into the Elnaz Go To dialog box and click to Go To The last three items in the Edit menu provide general useful facilities External variables Update categories Available user submodels View external variables Use Edit External en t UE variables to preview the oe 5 DE Nm Nm external variables as they will appear in AMESim when the submodel is saved Update categories Edit gt Update categories starts a reinitialization of the category icons the contents of the categories and associated data structures based on the current path list You will see the category icons disappear and be reconstructed List User Submodels A user submodel is a generic submodel which is stored in an AMESim node which is not the 4ME AME node or a sub directory of this node
16. If you set the following frequency of square wave Hz m values maximum values null it is very easy to show that the output from the integrator should be a wave of triangular form with minimum value 0 05 and maximum value 0 With a com munication interval of 0 1 second and the default maximum step size a typical output from the integrator is shown in Figure 3 31 70 AMESet 4 2 User Manual Figure 3 34 Bad results for first version of SQ50 1 INTU 1 output from integrator null 05 025 l O 0 25 0 5 0 75 1 1 25 1 5 1 sj 0 2 4 E B 10 Time z This is clearly unsatisfactory What is happening is that since the integrator 1s seeing a constant value from the square wave the step size 1s going to grow rapidly Sometimes it may find that output from the square wave switches to a completely different value In these circumstances the step will be rejected on accuracy grounds and be repeated with a smaller step size until the accuracy requirement is meet Alternatively the step size may give the situation shown in Figure 3 32 Here P corresponds to the time at the previous step and Q to the new step The accura cy requirement is satisfied and integrator will probably increase the step size even further Figure 3 35 AMESim takes a big step A N F q Since there is now a state variable reducing the Communication interval from the Run Parameter
17. Integer parameter 5 Insert new Text parameters E E K Cut l 142 2 L Submodel requirements ES Copy PERA ee ree ere Integer parameters E Integer parameter 1 Delete i Text parameters z Integer stores i Insert new Submodel requirements ah Cut Submodel requires time Es Copy Submodel requires discantini El 95 Chapter 4 Advanced examples 4 2 4 96 12 There is only one problem in the code generated the variable name is mode Type of parameter enumeration where in FX401 it was disc Change disc to mode Parameter details 13 Save and compile the sub model Tithe discontinuity handling Variable name disc Configure enumeration inactive Default value active In this example it was probably much quicker to do the changes without AMELexicon However if you construct a lot of submodels it becomes very important that titles and units are consistent AMELexicon is very good for this Activity index computations It is possible to create large numbers of very useful submodels that do not contain activity variables However there are strong reasons for adding these features if your submodels are to be used in serious big systems This 1s illustrated in Chapter 8 of the AMESim manual The current two submodels are certainly not likely to be used in serious big systems However to illustrate the process we are going to introduce activity index compu
18. Step 4 Create a new internal variable as follows w TE pan 4 2 7 AMESet 4 2 User Manual Note that minimum default and maximum values have been set to the same value This is a very useful trick because it means that the initial value cannot be set when the submodel is used under AMESim Only the submodel writer can reset this value directly This is because there is access to all state variables in the initialization routine of submodels If the value is not reset in the initialization routine it will have the default value 0 0 in this case This technique can also be used for implicit and fixed variables Step 5 Insert the code to perform the calculation of sdot Compile and debug as necessary Step 6 Use the submodel in AMESim together with BL57 Plot a graph of the total distance traveled Note how the distance approaches a value asymptotically Figure 4 56 Asymptotic curve of the distance traveled FL51 1 total distance traveled by object m iz 40 m EM 30 20 10 0 0 2 4 6 8 10 12 14 Time s Note also how BL50 and FL50 are a compatible pair as are BL51 and FL51 but you cannot pick and mix A final word on BL51 There are various ways of curing the problem One example is given below It required several attempts before it worked properly 107 Chapter 4 Advanced examples if flag eq O then Integration has just started or restarted Check value of y if y gt yO then
19. bat gcc Default Command line for DEBUG compilation ET Ecc DEBUG bat gee Default Fortran Compiler Command line for RELEASE compilation AMEF77_RELEASE bat Default Command line for DEBUG compilation AMEf77 DEBUG bat Default The DEBUG option produces code appropriate for a debugger that can understand the code produced by the compiler The RELEASE option produces code which is more efficient and compact but cannot be used with a debugger The files concerned are bat files under NT and sh files under Unix Probably the supplied files are all that is needed for 99 of users If you really do want to change them copy them from the AME system folder to another suitable folder and modify them Insert the name s into the appropriate slots and check that your modifications work You can enter the full pathname of this executable or you can enter just the executable name provided the path environment variable is set so that it can be found Color preferences This is exactly the same utility as in AMESim AMERun and AMECustom It is useful when you create a new category AMESet will display it initially in grey Use Color preferences to set a different color 145 Chapter 5 Reference Guide for AMESet Figure 5 13 The Color Preferences dialog box ME color Preferences lx Categories Description Color Mechanical ME E Default AMESet preferences Selecting this produces a AMESet Preference
20. gt gt gt gt gt gt gt gt gt gt gt gt Calculation Function Executable Statements vdot 9 81d0 fext mass ydot v C lt lt lt lt lt lt lt lt lt lt lt lt End of Calculation Executable Statements end 2 Optionally put checking code in the Initialization Function Check Statements of the initialization code There is a big temptation in these tutorial examples to omit this but for serious submodels it is highly desirable to do it C gt gt gt gt gt gt gt gt gt gt gt gt I nitialization Function Check Statements if mass le 0 0d0 then print Mass should be greater than 0 Value is mass error 2 endif C lt lt lt lt lt lt lt lt lt lt lt lt End of Initialization Check Statements if error eq 1 then Step 8 Compile the code and correct any errors found Step 9 Check that you can use it in AMESim 1 First verify that it will connect to icons in the green Mechanical library It should connect to any linear shaft port of a green icon that supplies a force Try these 81 Chapter 4 Advanced examples Figure 4 40 Check that the ball connects 2 Connect a single ball icon to a zero force source ringed in Figure 4 40 In Sub model mode show the external variables of the BL50 are what they should be Figure 4 41 External variables of BL50 3 With the default parameters run a simulation Plot various variables in the ball submodel Note how the ball falls freely under
21. high pP 142 Code DEneration a QUIT a RITU aoe TP 29 Color prelerences aus eod a tip e Loc de dd Pde CRA pel E Series s dni e rn ie 145 C OMIMOM UMS ici an aaa QU Gea ta ae qs 21 COMPANION esas odd ae tS ide REG Ob a ea eee alee 149 Compiler for Windows 46 OR OU tre ee eee eer ee ee Tee o aa da 150 AMS NAN tad Sense deine qmd end aa os 150 Comprst setos acreditada Rae Rawk eee ae eh edd eae 144 Component icon reati NeW uale Ma rine iba der wuerde ES Ped ie Us SUL qx 77 Configure enumeration dialog DOX 4 pes 24 00 Se PE ero eee ee eee at 91 Constiraimt yatiables esas artes Raw dh a sa 14 COPY arta ida dae DAA isa aa d 141 Create a new COmponent J 4 1 dd de Aa 152 Cubas cried ais od in elas 140 D IDEBUCI ODHOD ii AAA AA OR ae ew 145 Differential algebraic equations os uus A A 14 Dimension or a Variable 44 AA AAA 19 Discon MUY eene B aac eR e UR URDU ER Ode PDA Ac ena dio 26 76 Fa edu Sin data E A uaa a A aea qq etse 59 155 Regions exclusive and exhaustive 0 0 ee eee eens 87 Responsibility of submodel to detect 2 0 0 eens 76 CSI DU oso ego a A A ae a ee eee 61 85 A E E UE 61 109 CIS LETS ones iuri A a T d Aaa Aho scu Decio ioca am agen iu ee 61 Distributed parameter approach 0 0 ccc eee err 19 Documentation menu 0 ele 158 Duplicate van ables A RUE IE I b LA A ES Example A ae Ea eee ok ru Esa On tee ge ere Lie d 112 Revered SIDIT A sc fara rece a Ebr EN ee se ee eee 15 SAPE se
22. if flag eq 0 then if t ge tstart then AMESet 4 2 User Manual C Prime mover has started VEC d else C Prime mover has not started ic 1 0 endif endif if ic 1 eq 1 then C Prime mover has started omega omegaf 1 exp t tstart tau else C Prime mover has not started omega 0 C Register discontinuity at time tstart call distim tstart endif C lt lt lt lt lt lt lt lt lt lt lt lt End of Calculation Executable Statements end In C ifdef NO PROTO void pm51_ n omega rp ic flag t int n double omega double rp 3 int ic 1 int flag double t else void pm50_ int n double omega double rp 3 int ic 1 int flag double t endif int logi gt gt gt gt gt gt gt gt gt gt gt gt Extra Calculation Function Declarations Here lt lt lt lt lt lt lt lt lt lt lt lt End of Extra Calculation declarations 63 Chapter 3 Getting Started double omegaf omegaf rp 0 tstart rpl1l rp 213 tstart tau tau Set all submodel outputs here omega Es PO Di gt gt gt gt gt gt gt gt gt gt gt gt Calculation Function Executable Statements if flag 0 fue Initialization call 1 t gt tstart Prime mover has started ic 0 1 else Prime mover has not started elo Ds if ic 0 1 omega omegaf 1 exp t tstart tau
23. is used to register discontinuities which occur at a known time Note that great care is needed to ensure complete consistency Thus if the following statements had been used In F77 if t gt tstart then Leti ses endif instead of if t ge tstart then Bed sel endif if t gt tstart ic 0 1 j instead of if t gt tstart ic 0 1 there could have been a major conflict A discontinuity could have been located at time tstart and a restart organized The ic 1 or ic 0 variable would then have been set to 0 and another discontinuity located at time tstart followed by another restart What would happen after this is rather unpredictable To summarize Discontinuities involve changing from one regime mode or state to another Each regime has its own set of continuous equations It is of the greatest impor 65 Chapter 3 Getting Started tance that the code for detecting a change of regime should be totally consistent with the code for setting the regime In the present example you are using condition for regime condition for leaving regime ms t It tstart t ge tstart t ge tstart t It tstart Or condition for regime condition for leaving regime sO t lt tstart t gt tstart t gt tstart t lt tstart However note that in this example since time does not go backwards you do not need to test for leaving the region corresponding to ic 1 1 in F77
24. the three conditions are exclusive and exhaustive Naturally the initialization function should check that xmin lt xmax You will now construct a submodel for our floor icon The submodel will use the code for handling the discontinuities in the manner described above and also code which ignores discontinuities This will enable you to see the two techniques compared in terms of run times accuracy etc To enable us to switch from one mode to the other an integer parameter will be used These are similar to real parameters but since they are integers do not have units They are chiefly used to allow you to select from several options Step 4 Set the integer parameter in the same way as the real parameters A suggested name for this parameter is mode and for the title minimum default and maximum values 87 Chapter 4 Advanced examples Type of parameter standard Type of parameter standard standard enumeration 1 for discontinuity handling 2 for ignore discontinuities Step 5 Generate the code in your preferred language and make insertions in executable section of the calculation routine In Fortran these will be In F77 if mode eq 1 then C C Full discontinuity handling selected C if disimp y ge y0 ic 1 then C e The object is in contact with the floor C fext k y yO damp v else if disimp y lt yO ic 2 then C e The object is free of the floor C fext 0 0d0 endif else C
25. 0 and hence y will be changed so that y y0 It follows that the first branch is always selected e When the condition y lt y0 is false the first branch will still be executed This is essential to ensure that the equations are continuous As soon as the condition is false the function disimp will scream and the integrator will locate the discontinuity and organize a restart During the first call after the restart flag 0 and y will be reset and so the condition y lt y0 is true again It follows that we can delete the second branch completely If you are very observant you will notice that if the starting value of y was set such that y gt y0 and in addition v lt 0 there would be a major problem The value of v would be reset to a positive value and the ball would be traveling downwards This would trigger a discontinuity immediately after the first integration step We make the following modification in an attempt to cope with this if flag eq 0 then C C Integration has just started or restarted C Check value of y C if y gt y0 then C C Ball has hit the floor C y yo AMESet 4 2 User Manual lf v gt 0 0d0 then v coefr v endif endif endif ut disimp y le y0 ic 1 Jthen C C Ball is still falling freely C ydot v vdot 9 81 endif Again if you are very observant you will notice that if initial value of y is set to y0 and v 0 there will be major problems However it is time to get s
26. 1 Set derivative of rotary speed dtheta omega lt lt lt lt lt lt lt lt lt lt lt lt End of Calculation Executable Statements SI gt Common units conversions 120 AMESet 4 2 User Manual Step 9 Compile the new submodel and debug as necessary Step 10 Test the new submodel in AMESim with the following system use all default values and run the simulation with a final time of 1 second Figure 4 61 System for testing the crank submodel The interesting point is the following information in the System compilation dialog box Figure 4 62 AMESim detects an implicit loop Creating a simulation program for your system Number of states 1 Terminated Number of implicits 1 Where did the one implicit variable come from The answer is from another algebraic loop Create a State Count dialog box to find out what it is Figure 4 63 State count dialog box Summary of which state variables controlled the integration step size State MO centres Submodel CRANKS 1 angular position of crank degree gt DAMOGO 1 force at port 1 N Remember AMESim tries to sort the submodels into a calling sequence so that as each submodel is called all its inputs are known In this case it is impossible e We cannot call the damper submodel DAMO000 and calculate the force output until the velocity input is provided by CRANKS e We cannot call CRANKS to calculate this velocity until the force is provided by DAMO000 AMESi
27. AMESim Parameter Mode Preview 4 AME Sim Parameter Mode Preview Ei ES Submodel CRAHKO External variables ideal crank without friction or Inertia angular position of crank O degree radius of crank 30 mm length of connecting rod 40 mm offset for displacement O mm Options gt gt Preview submodel variables This shows you how the active submodel will look in the AMESim in the Ie Variable list dialog box The facility is also available by clicking on the button in the tool bar box The facility is also available by clicking on the button in the tool bar Use this facility frequently to check that what you are getting is really what you want Figure 5 6 AMESim Run Mode Preview E AME Sim Run Mode Preview El ES Submodel CRAHKU External variables ideal crank without friction or inertia displacement port 2 force port 2 angular position of crank angular position of crank modulo 360 transformer ratio 156 null Hm null rev min null m z null m null M null degree null degree null m AMESet 4 2 User Manual 5 4 6 Code menu Code Tools Docume Type Generate FS Edit FE 3 Compile F7 Type Code Type allows you to select the type of source code generated C or F77 and the type of object code generated release or debug Debug object type allows you to use a suitable debugger if you include your submodel in an AMESim system Release object type does n
28. C The object is free of the floor C fext 0 0d0 endif Remember the sign convention which is shown in Figure 4 43 If y y y0 and v are positive which will be the case when the ball is in contact with the floor both the spring force and viscous force will act upwards i e will make a positive contribution to fext Figure 4 43 The ball falls to the floor ES PT eee y yO fext pP These lines of code are simple and express exactly what we want to do However unfortunately they completely ignore the discontinuity To handle the discontinuity it is necessary to ensure the integrator always works on continuous equations We could modify the second branch of this code as follows else if y 1t yO then The object is free of the floor rext 0 000 endif AMESet 4 2 User Manual Clearly this does exactly the same thing Finally we modify the code as follows if disimp y ge yO ic 1 then C C The object is in contact with the floor C fext k y yO damp v else if disimp y lt yO ic 2 then C C The object is free of the floor C fext 0 0d0 endif and this achieves our objectives There are two key features in this code which must now be explained First there are two integer store array elements ic 1 and ic 2 Remember that these elements have their values preserved between calls The function disimp will set these to either 1 or 0 which are taken to be true and
29. Can check and reassign values of explicit states variable print Illegal value of print displacement Resetting to print xmax x xmax if error ne 2 error 1 endif Implicit state See above Can check and reassign variable values of implicit states Constraint Normally you do not write any code Can check and reassign variable values of constraint variables but this is not normally necessary Duplicate No code There is no access to variable duplicate variables in the initialization function On line macro No code There is no access to variable one line macro variables in the initialization function Multi line macro No code There is no access to variable multi line macro variables 1n the initialization function Fixed variable 1 0d0 then Can check and reassign 8H EROS value to low values of fixed print Resetting to 1 bar p 1 0d0 variables if error ne endif 187 Chapter 5 Reference Guide for AMESet Type of variable Example of code in calculation Comment function subroutine Basic variable Explicit assignment which an output any internal any external output Explicit state vdot force mass Explicit assignment of variable derivative of explicit state if flag eq 0 then The state variable may HQ sc SIE Ene be reassigned only if xX xmax endif flag 0 endif Implicit State vdot is the derivative on entry Derivative and residual variable oom A tan
30. Click on the column Value and type in a name for the internal variable This name will be used in the submodel code Dimension Click on the column Value and type in a dimension for the internal variable Minimum expected value Default value and Maximum expected value These characteristics are available for internal variables the type of which is explicit state implicit state constraint or fixed variable They are assigned by clicking on the column Value If the three values are identical the internal variable will not appear in AMESim and it will not be possible to change its value Variable derivative name This characteristics is only available for internal variables the type of which 1s explicit state Click on the column Value and type in a name for the derivative of the internal variable This name will be used in the submodel code Variable residual name This characteristics is only available for internal variables the type of which is implicit state or constraint Click on the column Value and type in a name for the residual associated with the internal variable This name will be used in the submodel code Residual unit This characteristics 1s only available for internal variables the type of which is implicit state or constraint Click on the column Value and type in the unit of the residual associated with the internal variable Alternatively you can click on the button B in the column and you will get a dialog box for
31. RHOTE VANEY SOURCE IMAGINE Roanne 42 5 rue Brison 42300 ROANNE tel 33 04 77 23 60 30 FRANCE fax 33 04 77 23 60 31 eA RR RARA RARA RARA kk ck A ck ck AA RRA ARA RARA RARA RARA k k k ck ck kk kk k k k k k Y gt gt gt gt gt gt gt gt gt gt gt gt Insert Private Code Here lt lt lt lt lt lt lt lt lt lt lt lt End of Private Code There is 1 real parameter rp 0 radius radius of the pinion mm m E There are 0 integer parameters 42 dd There are 0 text parameters ifdef NO PROTO void rack50in n rp x int n double rp 1 double x Helse void rack50in int n double rp 1 double x endif int error 0 gt gt gt gt gt gt gt gt gt gt gt gt Extra Initialization Function Declarations Here lt lt lt lt lt lt lt lt lt lt lt lt End of Extra Initialization declarations double radius radius rp o0 If necessary check values of the following rp 0 0 x 27 gt gt gt gt gt gt gt gt gt gt gt gt Initialization Function Check Statements if radius 0 0 fprintf stderr nPinion radius cannot be 0 n error 2 lt lt lt lt lt lt lt lt lt lt lt lt End of Initialization Check Statements if error 1 fprintf stderr nWarning in RACK50 instance d n n else if error 2 fprintf stderr aFatal error in RACK50 instance d n n fprintf stderr Te
32. allow exchange of information between submodels The primary function of a submodel is to calculate its outputs from its inputs Chapter 2 AMESim Submodels 2 6 In the previous section we stated that the order in which AMESim calls the submodels during the integration is special The idea is that AMESim tries to sort the submodels into an order such when each submodel is called all its inputs are known We say tries because sometimes no such order exists In such circumstances we say there is an algebraic loop also called an implicit loop AMESim gets over this problem by introducing special implicit variables that break the algebraic loop It is hoped that the elementary AMESim user never has to think of these things However the submodel writer must be aware of this problem and must try to minimize algebraic loops Local variables and internal variables In a typical submodel there will be many variables including some that are not external variables Normally these are variables which only exist inside the submodel code and are totally inaccessible outside the submodel These are known as local variables Sometimes it is desirable to have a variable for plotting that is not an external variable because it is not needed by any another submodel AMESim allows for this situation by having internal variables These are like external variables but are not associated with any port and are neither inputs nor outputs The angle sensor subm
33. allow them to behave like submodels in there own right This is precisely what we do There are three ways of extracting equations from AMESim submodels duplicate variables simple or reversed sign which you have seen al ready one line macros e multi line macros Step 11 If necessary reload CRANKS Step 12 File Save as specifying CRANK6 We have decided that there would be big advantages to extracting the calculation of the linear velocity from CRANKS We might as well extract the displacement as well If the damper had needed the displacement this would have contributed to the implicit loop Step 13 Load the details of port 2 external variable 2 specifying the linear displacement Change this to a one line macro as follows AMESet 4 2 User Manual Figure 4 65 Change the value to a one line macro por 2 A estemal variable z zi External variable settings Variable generalities Setting E Type of variable Variable can be plotted rue Variable details Setting Title displacement part 1 Unit m Variable name Expression c 1 cos theta s sqiiL L c1 c1 sin theta sin theta The one line macro is a light weight version of the multi line macro We must define the expression in a single line The expression can contain the following suitable variables referenced by their name theta in the current exam ple suitable real parameters referenced by their name Z in the curr
34. and so it was kept very simple However experience has shown that it is extremely convenient to work entirely within AMESet and hence it is now much more powerful On the other hand users have very individual tastes and preferences concerning editors and if you want to use another editor it is very easy to change Use the following procedure Step 1 Step 2 Disable untick the Use AMESet fallback editor check box Enter the name of the editor executable you wish to use You can enter the full pathname of this executable or you can enter just the executable name provided the path environment variable is set so that it can be found Alternatively you can use the browse button to search for it In this tab you can also select the HTML editor you wish to use from AMESet 147 Chapter 5 Reference Guide for AMESet If the fallback editor is enabled Two radio buttons control what the tab key does If Keep tabs is enabled an invisi ble tab character 1s inserted 1nto the text and the delete key re moves it If nsert spaces is en abled the specified number of spaces 1s inserted and the delete key will remove one space Tabs Keep tabs Insert spaces Number of spaces 3 Clicking on Select font button creates the Select Font dialog box as shown in Figure 5 16 Use this to select a font for the text appearing in the editor Figure 5 16 The Select Font dialog box Pil Select Font Centu
35. better if you generate the submodels and edit them to create the submodel code Remember that submodels rarely work first time and you will learn far more if you make a few mistakes and correct them When the author of this manual constructed the submodels described they certainly did not all work first time The development and refinements that can be applied to each submodel is almost unlimited In particular it is good practice to insert statements checking the values of various parameters and to fill in the description section for each submodel This 31 Chapter 3 Getting Started does tend to be very time consuming and is perhaps too tedious for a tutorial exercise For this reason at certain points in the exercises it is suggested that you do copy the submodel code from the AME tutorial submodels or AME tutorial submodels directory and examine it in an editor Submodel name conventions e AMESim submodels have names of 4 to 23 characters comprising uppercase letters and digits e Inall AMESim library submodel names if there are any digits the first digit will be in the range 0 to 4 e Hence if you create submodels with names that contain at least one digit and if the first digit is in the range 5 to 9 there will be no name clashes with existing standard submodels 3 2 A rack and pinion submodel with calculation of angular position The rack and pinion submodel RACKO00 is available in the AMESim mechanical standard librar
36. changed to any Default value active of the string values the parameter can take However leave the string as active Do a Parameter Mode Preview and note how you can change the text string for the enumeration parameter Figure 4 47 Parameter mode preview for the enumeration integer parameter Parameters displacement at which impacting object hits floor spring rate between impacting object and floor damping coefficient between impacting object and floor 7 Save your submodel 8 What changes need to be done to the code Actually none Look at the code in your editor You will find it looks very similar to how it did when it was a stan dard integer parameter Within the generated code is a integer parameter taking the value 1 to 2 just like when it was a standard integer parameter The text string active and inactive appear only in the Change Parameters dialog box 9 Compile your submodel and reselect it in AMESim verify than the Change Parameter dialog box is different but it gives the same result Using AMELexicon to set parameters 92 AMELexicon is a tool dedicated to helping you achieve consistency in submodel titles units etc Many submodels contain an enumeration integer parameter like the one we want to create We can use AMELexicon to find these and copy paste into FL50 We now review the stages for changing the standard parameter to an enumeration parameter using AMELexicon We assume that starting po
37. double rp 3 int ic 1 int flag double t else void pm50_ int n double omega double rp 3 int ic 1 Hendif int flag double t int logi gt gt gt gt gt gt gt gt gt gt gt gt Extra Calculation Function Declarations Here lt lt lt lt lt lt lt lt lt lt lt lt End of Extra Calculation declarations double omegaf tstart tau omegaf rp 0 tstart rp 1 tau rp 2 Set all submodel outputs here omega PO of gt gt gt gt gt gt gt gt gt gt gt gt Calculation Function Executable Statements if t gt tstart omega omegaf 1 exp t tstart tau omega 0 0 lt lt lt lt lt lt lt lt lt lt lt lt End of Calculation Executable Statements Note AMESet has kept your lines of executable code provided you put them in the approved place An extra variable called flag has appeared on the argument list This is the discontinuity variable and plays an extremely important role in the handling of discontinuities A variable named logi has been declared which is of type int in C code and ogical in the Fortran code In the Fortran code subroutines named disloc and distim are declared on external statements and the logical function disimp is also declared on an external statement These utilities will be called to handle discon tinuities as they occur 61 Chapter 3 Getti
38. external variables 3 pa Port 2 external variables fi gt onm a0 173 Chapter 5 Reference Guide for AMESet After this you must define further their characteristics See Setting the characteristics of an external variable page 176 Declaring internal variables These variables are available for plotting but they are not associated with any ports and they are neither inputs nor outputs To declare internal variables 1 Select Internal variables amp Intemal peers E 2 Edit the Numbers field directly or using the spin box arrows After this you must define further their characteristics See Setting the characteristics of an internal variable page 178 Declaring real integer text parameters These parameters are used to define the size or characteristics of the submodel They can be real quantities integer quantities or text expressions To declare parameters 1 Select Real parameters Integer E Real parameters parameters or Text parameters Integer parameters 2 Edit the Numbers field directly or using i Text parameters the spin box arrows After this you must define further their characteristics See Setting the characteristics of a real parameter page 180 Setting the characteristics of an integer parameter page 181 and Setting the characteristics of a text parameter page 184 Declaring integer real stores Stores are arrays that are accessible in
39. follows Figure 4 67 Velocity as a one line macro pot 2 H estemal variable 1 External variable settings Variable generalities setting Type of variable one line macra Variable can be plotted True Wanable details Selling Title velocity part 2 Unit m s Variable name vel Expression tfratia omega Step 16 Take the torque which is port 1 variable 1 and modify as follows Figure 4 68 Torque as a one line macro port al estemal variable 1 External variable settings Variable generalities Setting Type af variable one line macro Variable can be plotted True Variable details Title torque port 1 Unit Hm Variable name torg Expression tratio force Step 17 Generate code and load into an editor First note that a double precision double in C function has appeared in which we must define fratio This function has a section where we can make declarations and another where we insert executable statements Note e The multi line macro variable function subroutine is like the calcu lation function subroutine except that it returns a value thas access to all the same real integer and text parameters and real and integer stores 125 Chapter 4 Advanced examples e If the Submodel requires time box is ticked it has access to f e Ifthe Submodel requires discontinuity flag box is ticked it has access to flag In the crank6 subroutine or crank6_ fu
40. for AMESet If you click on one of the icons you get a Submodel List dialog box Figure 5 3 The Submodel List dialog box io Submodel List El ES elasticendstop Submodel list NEW SUBMODEL Select this line to start a new submodel new submodel LSTPODA elastic contact no states generic submodel LSTPOU elastic contact generic submodel External variables Help You can select from the list an existing submodel or a new submodel with the icon associated with it This is the most common way of initiating work on a new or existing submodels but see also New page 135 and Open page 136 5 4 The AMESet menu bar Each menu allows you to access the main AMESet commands See the details in the following sections 134 9 4 1 Fil New k AMESet 4 2 User Manual e menu Figure 5 4 The file menu File Edit Options Icons Submodel Code Toole Docume 3 New Ctrl Ca Open Ctri O Save Chrl 5 Save as E Print Ctrl P Restore backup 1 FAME Sim ved 2 0rtutorial submodels FL50 spe PAME Sim v4 2 Osubmodels FEAUT spe a PAME Sim v4 2 0rtutorial submodels BL50 spe 4 CAS FTP DE submadels FLBU spe Close Quit Erbe Use File New to initiate the process of opening a blank submodel specification It will not be associated with any icon and will have no proper name Figure 5 5 The short cut is CtrI N The facility is also available by clicking on the icon in the tool ba
41. is used to present the system sketch will be used to display details of submodels and icons Figure 3 2 The AMESet display il AMESet File Edit Options Icons Submodel Code Tools Documentation Windows Help 33 Chapter 3 Getting Started 1 At the left hand side of the AMESet display are the Categories but tons Select the Mechanical category and then click on the standard e rack and pinion icon The dialog box below will appear Figure 3 3 Submodels associated with the icon rack2 E Submodel List Submodel type NEW SUBMODEL Select this line to start a new submodel new submodel HALK L rack and pinion linear velocity input at part 1 generc submodel HALEUT rack and pinion rotary velocity input at port 2 generic submodel External varieties Help Cancel He Select the submodel RACK00 in the list and click on OK Figure 3 4 shows the new display Figure 3 4 RACKOO loaded into AMESet fi AMESet RACKOO spe amp File Edit Options Icons Submodel Code Tools Documentation Windows Help External variables Internal variable port 1 z extemal variable 1 a Vanable generalities Variable can be plotted True Change icon Brief description rack and pinion linear velocity input at part 1 2 l Ports Port 1 extemal variables 2 Ishatt pu External variable 1 e Vanable details Submodel requirements Expre
42. j Or 3 Inthe right part of the main window click on the Integer parameter tab 4 Adjust the integer parameter number by Integer parameter 2 using the arrows on the spin box Real parameters Integer parameters Integer parameter generalities There are two types of integer parameter standard and enumeration Set the integer parameter type ee Value standard standard enumeration Integer parameter details Regardless of the integer parameter type the following information must be given 1 Title Click on the column Value and type in a title for the integer parameter This title will appear in AMESim when you will use the submodel 2 Variable name Click on the column Value and type in a name for the integer parameter This name will be used in the submodel code The remaining information to be provided depends on the integer parameter type Parameter details for standard integer parameters Minimum expected fixed value Default fixed value and Maximum expect ed fixed value These characteristics are assigned by clicking on the column Value If the three values are identical the integer parameter will not appear in AMESim and it will not be possible to change its value Parameter details for enumeration integer parameters Note The enumeration facility is extremely powerful It require great care to set it up well but the result is a submodel that is very easy to use When you use enumeration m
43. mail support uk amesim com GERMANY AUSTRIA FINLAND DENMARK NETHERLANDS NORWAY SWEDEN SWITZERLAND EASTERN EUROPE IMAGINE Software GmbH Tel 49 0 89 548495 35 Fax 49 0 89 548495 11 E Mail hotline germany amesim com HUNGARY Budapest University of Technology amp Economics Tel 36 1 463 4072 463 2464 Fax 36 1 463 3464 E Mail vad simba ara bme hu AMECustom 4 2 User Manual NORTH AMERICA IMAGINE Software Inc Tel 1 734 207 5557 Fax 1 734 207 0117 E Mail support us amesim com SOUTH AMERICA KEOHPS Ltd Tel 55 48 239 2281 Fax 55 48 239 2282 E Mail info keohps com JAPAN IMAGINE Japan K K Tel 81 0 3 3351 9691 Fax 81 0 3 3351 9692 E mail imagine japan amesim com CHINA IMAGINE china Tel 86 21 34 12 34 58 E mail qing amesim com United Right Technology Tel 86 10 67082450 52 53 54 Fax 86 10 67082449 E Mail urt urtgroup com SOUTH KOREA SHINHO Systems Co Ltd Tel 82 31 608 0434 Fax 82 31 608 0439 E Mail iclee shinho systems co kr ISRAEL Tel 972 3534 4432 Fax 972 3535 5514 E mail fempp netvision net il
44. methods have no problems when integrating along C1 but at point P problems arise If no special precautions are taken as in the following pseudo code if condition use formula for C1 else use formula for C2 endif The integrator will drastically reduce its step near the point P in a desperate attempt to meet accuracy requirements Many integrators will give up with an error message when the step gets too small Others will have a minimum step size and when this 1s reached will carry on even though the accuracy requirements are not met The first approach leads to frustration and the second can lead to highly inaccurate results In the past many simulation packages accepted this situation but now it is almost universally recognized that discontinuities should be handled in a more careful manner The idea is simple in concept If the solution is on curve C1 and goes past the point P then the equation for C2 is not used Instead the equation for C1 is still used so that effectively the curve Cl is employed This gives rise to a point Q being predicted The integrator must then realize that a discontinuity point has been passed over and start trying to locate it This can be done in two ways Either the integrator tries with a series of smaller steps sizes or some form of interpolation is used Either way the point P is located within reasonable accuracy or even to machine accuracy After this the integrator is restarted forgetting all in
45. of the next section Real and integer stores An option available for submodels is to have real and or integer arrays known as real stores and integer stores These arrays are accessible in both the initialization and calculation routines They can be used for whatever purpose you like The important point is that they retain their values between calls Here are some common uses of real stores e Used to store expressions calculated in the initialization routine and then used repeatedly in the calculation routine e Used to store the final value of an iterative scheme calculated in the calculation routine which will be used as a starting value the next time the submodel is called Used to store tables of information read from files in the initialization routine and used for interpolation in the calculation routine The most common use of an integer store is to store an index number for a particular mode that changes as the simulation progresses This is extremely important when the submodel features discontinuities This important topic will now be addressed Discontinuities What is a discontinuity A good example occurs in modeling a hydraulic actuator or jack The physical dimensions of the jack body limit the movement of the piston If the piston is moving within the jack body and reaches the limit of its travel it must be brought to rest Often devices incorporate cushion so that the piston is brought to rest over a finit
46. riada daten denen dieque 8 Imiplicitstate Variables owes tote we baat ooo ached weet o a he sheds 13 TITAS RAO IIMS DOR He E A duni eee orsdesca mt ames ot ee ete d uten a aha al erecta 129 Initialization functions subroutines o 25 TRUE Gase rta nc Re e ae oo ed Ag ard ae he Soa le oes Sep ee aav ses 10 130 Inpat witbidetaule 22d eed or c SERI a A M RS MERE ene aes 10 PUSE ai ea ad NAE 7 Integer parameters rol ar E a eet am dd a Peewee we 23 181 PEn tbetatioti ads nto ae ee tdt aho owe Saath arab 24 90 III AP we eet ane ee hk nek wat CAE eth ees 24 87 Standard and Enumeration 2525 o Yet x tiene Saco X ES ee ele ha au eee 181 Inte POT SIDE S ce Aantal anos awed Ct GRE Meee keane eot addu abu uda 26 Internal Variables canada Soham dow dieere de nti ded Sew are dco rede es 8 178 IS Oa da ere HOO uou obtenue S aue dem mae don ed aut das S d eh aL aot days 177 179 180 L Lastopeneud TESSE 402 5352 593 8 Sl AERE ADR e e 140 LENSE VIS WET Ae A IDOL DUCES ap es a aie daa eae 162 Eine submodels oscila Ua Se LR OR eg Quom Md Ree 129 List UW ser SubmodelS eiii E 142 Locabyarables tar ida as das 8 Lumped parameter appro dc esti nr noe Ue Unis n aid o PE ao ee eee 19 M Macro variables IDG HoCOVeL USE oue cuter a pasen ped usc S a et har diu tx besar ene 128 Index Menu DAT ri TUR PEN a sexe Mao ara tse det 134 Minimum default and maximum values lees 20 Move DOWN lada ee estate Ra pedet fade vade adi cr Matar e MEE 141
47. selecting the unit as in Figure 5 25 179 Chapter 5 Reference Guide for AMESet 10 Physical type Physical domain Variable name suffix These characteristics are only available for activity variables The Physical type is selected from a list it can be set to R C or J The Physical domain is also selected from a list it can be set to hydraulic mechanical electrical thermal magnetic or pneumatic The Variable name suffix must be typed in it will be used by AMESet to generate the name of the power variable associated with the activity variable Setting the characteristics of a real parameter 180 There are two ways to select an real parameter l In the left part of the main menu expand the Real parameters tree structure in the 7ype column until you i Real parameter 1 see the real parameter you want MER eal parameter 2 Heal parameter 3 Click on 1t or In the right part of the main window click on the Real parameter tab Adjust the real parameter number by using real parameter 3 the arrows on the spin box Internal variables Real parameters Real parameter details In order to define a real parameter the following information must be given l Title Click on the column Value and type in a title for the real parameter This title will appear in AMESim when you will use the submodel Unit Click on the column Value and type in the unit of the real parameter Alternatively you c
48. the Activity Computation Statements section define the power associated with the mass of the ball The power is obtained by multiplying the force mass vdot by the velocity ydot C gt gt gt gt gt gt gt gt gt gt gt gt Activity Computation Statements powlmass mass vdot ydot C lt lt lt lt lt lt lt lt lt lt lt lt End of Activity Computation Statements Step 5 Compile and save BL50 Activity index in the floor submodel 98 Concerning the floor submodel we will use two activity variables that will be associated with the capacitive spring and dissipative damper power of the submodel Step 1 Open the floor submodel FL50 Step 2 Set the number of internal variables to 2 set their type to activity variable and define them as follows Step 3 Edit the submodel code 1 In the Activity Computation Statements section define the power associated with the capacitive and dissipative elements of the floor submodel In a linear mechanical submodel the power is obtained by multiplying the force by the velocity For the dissipative R element the force is damp v and the velocity is v For the capacitive C element the force is k y y0 and the velocity is v Thus we get C gt gt gt gt gt gt gt gt gt gt gt gt Activity Computation Statements powCspring k y y0 v powRdamper damp v v C lt lt lt lt lt lt lt lt lt lt lt lt End of Activity Computation Statements 2 Check t
49. the use of AMESet An AMESim node is any folder or directory which is used as the root of a storage area by e AMESet for generic submodels e AMESim for generic supercomponents e AMECustom for customized submodels and supercomponents Below is shown a typical structure of an AMESim node Figure 5 1 AMESim node C data J doc E libes CI Icons 0 data C lib EC dac a Icons 3 lib mg submodels 131 Chapter 5 Reference Guide for AMESet The folders are used as follows Ep ae mao cda to store details of submodels and supercomponents associated with the node only ifa category Used to store category icons and icons of has been created components stored in the category specifically for this node only if a user The preferred place to store an archive creates 1t library a or lib manually data only if a user The preferred place for any data files creates it manually doc always The preferred place to store any documentation files such as HTML The files in the AMESim node are as follows submodels inde always Used to associate submodels and bs supercomponents with icons AMEIcons only if a Used to specify the files of the category category 1s associated with the node created AME make only if created Used to modify the behaviour of the manually facility that creates or makes the executable of an AMESim model Files in the Icons folder The xbm files define the icon
50. to be an algebraic or constraint variable Constraint variables may be internal or external variables If they are external variables they are always regarded as outputs However submodels do not compute constraint variables as these are computed by the integration algorithm Instead they compute a quantity called the residual This is the quantity that should be zero but in practice would be at best a very small quantity In MAS000 the residual is pod ZA The integrator will adjust v in an attempt to make zero by an iterative process In order to do this a starting value must be provided This is normally set using the Change Parameters dialog box for the submodel Sometimes it is difficult to set this value to anything other than a very arbitrary value The equations being solved are now a mixture of differential and algebraic equations and are referred to as differential algebraic equations d a e s as opposed to differential equations or more precisely ordinary differential equations o d e s However often the algebraic equation part of the whole model is far more difficult to solve than the purely differential equation part One of the problems is that an algebraic equation may have 2 11 2 11 1 AMESet 4 2 User Manual aunique solution no solution e multiple solutions or even e aninfinite number of solutions A d a e solver has a hard task to perform and can be excused for being less reliable than a
51. use mm or a dimensionless fractional spool position Another bad example is in the field of magnetics where the SI unit of magnetic flux is Wb where as most engineers would prefer to express these quantities in UWb Units such as bar L min rev min and uWb will be referred to as Common units The problem is acute if the variable is a state or constraint variable since numerical complexities can arise The integrator must estimate the error in the step for each state variable and constraint variable y 21 Chapter 2 AMESim Submodels 22 The most general error test for the variable is LP lt ej where 7 and T are error tolerances There are three common error tests 1 If7 1 and 7 0 the test is called an absolute error test 2 If t 107 and 1 1 the test is called a relative error test We use a small value such as 107 instead of 0 to prevent problems when y crosses zero 3 Ift 1 and 7 1 the test is called a mixed error test When y is very large this is a relative error test and when y is very small it is an absolute error test Normally the mixed or relative test 1s used These works extremely well provided the variables are well scaled By this we mean that the maximum value of a state implicit variable in the course of a simulation satisfies Z3 107 lt ly Variables that are constant and zero are excluded from this test This excludes values in Wb and m s By having a different t and
52. variable you want 2 Click on it l Forts 3 Inthe right part of the main window click on the External variables tab 4 Adjust the port number and variable number by using the arrows on the spin boxes Part 1 external variables Extemal variable 1 gc temal variable 2 Or External variable 3 External variables Internal variables port 1 extemal variable 2 In order to define an external variable the following information must be given Variable generalities 1 Type of variable It is chosen in a list you get by clicking in bs usas the column labeled Value The default type is basic variable 2 Input output status This characteristics is only available for external variables the type of which is basic variable It 1s chosen from a list you get by clicking in the column labeled Value The default status 1s undefined but you must change it to something else before you can save the submodel 3 Variable can be plotted This characteristics is only available for external variables of type basic variable fixed variable one line macro or multi line macro It is chosen in a list you get by clicking in the column labeled Value It is either True or False The default state is True 4 Duplicate type This characteristics 1s only available for external variables the type of which is duplicate variable It is chosen in a list you get by clicking in the column labeled Value It is ei
53. 1 for each state constraint variable y and manually adjusting each tolerance value individually it is normally possible to get good results even if the state constraint variables are badly scaled However this is a tedious operation on a small system and totally impracticable on large systems AMESim adopts the strategy of encouraging the use of well scaled variables and using a default mixed error test This implies the use of non SI units on occasions To summarize SI units no conversion necessary but sometimes badly scaled Common units conversion factors necessary but well scaled To avoid calculations in non SI units the AMESet code generation facilities give the option of automatic conversion between SI and common units Use this facility This gives the advantages of both SI and common units AMESim extensively uses the following common units hydraulic flow rate L min e pressure bar e spool position as a fractional value null rotary speed rev min e magnetic flux uWb AMESet 4 2 User Manual 2 17 Plot access to external and internal variables It can be useful sometimes for the submodel writer to pass information through variables at ports and hide some variables from the AMESim user to make the submodel clearer AMESim AMESet permits the submodel writer to specify that a variable cannot be plotted by the user Such a specification is made during the design of the submodel 2 18 Time as a submodel input
54. 24 2 20 AMESet 4 2 User Manual Integer parameters do not have units but AMESim insists that all real parameters do have units If you feel that a real parameter does not have units set the field to null If the option of conversion to SI units is used code will be inserted by the automatic code generation facilities near the end of the initialization part This code will convert the real parameters from common units to SI units Text parameters are collections of one or more character arrays The most common use is to store the names of files A more sophisticated use is to store an algebraic expression in terms of one or more variables which will be evaluated in the submodel Text parameters have four attributes e a title that will be displayed in the Change parameters popup e a default value for the text parameter e the current set value of the text parameter and e a Text type field which can take three values It is unfortunate that text arrays are stored rather differently in the C language than in Fortran 77 For this reason text parameters are only allowed in submodels written in C The SORA a8 l undefined form of the initialization and calculation code will now be yeee Text type input file gt Initialization and calculation routines The code of an AMESim submodel is written in C or Fortran 77 F77 In either case there will always be two modules of code functions if it is written in C or subroutines if in
55. 3 2 4 2 9 2 6 2 2 8 2 9 2 9 1 29 2 2 10 2 11 2 11 2 11 2 11 2 47 2 13 2 14 245 2 16 27 AMESet 4 2 User Manual contents troduction A aoe eas NU sae Vere ties 1 Nas AMESE A tae ware Quien ae Se ee l AMESet functionality i ep eem CROCO a l Add and remove a component category o o oooooooooommoooo 1 Add edit and remove a component icon in component category l Create a submodel specification nananana nananana eee ee 2 Generate a submodel code skeleton 000 cece eee 2 Organization of this manual 0 0 0 0 ccc eee teen 2 AMESim Submodels ta es ee AR EE RAE ERAS VERE PY xd 5 NERO GUC TO Ms 2d ic Ed et leo 5 The structure of an AMESim simulation program 5 Variables and parameters 44 aucta oc Phas e WEEE epi See oe es 6 Ports and external variables oeste ERE ES ds 6 Inputs and OUIpulsa etes dee Red 2b ASA nated eee 7 Local variables and internal variableS oooooooooo o oo 8 Types ob VartdbleS daa tado etat ac er E eee Aat dod 9 Basto Y arable iii a Ce obere Pod eek E edd 10 Didte ValHables 6420 see eame ca be RA 12 Explicit state VanlaDles yc dep bordo ERE hs pro bae ob its 12 Iraplicitstate yariableSs 2 404 404 oo ea ee ere cem Eee Re eee kets 13 Constraint variables ioo 53 A AA 14 Duplicates one line and multi line macro variables 15 LE Duplicate Varta lessee caca dm las daa tea d 15 2 One line MACTO us 6545 ERE d
56. 50 100 150 200 15 753 FPROP 1 input pressure bar D 50 100 150 200 1 FPROP 1 absolute viscosity cP 5 0050 A EDO 9 0007 E ceni d 4 99970 FPROP 1 input pressure bar 4 99950 5 50 100 150 200 You can now adjust the FP50 parameters in order to get closer to the characteristics of the fluid you want to simulate The submodel skeleton FP51 is similar but it is constructed to make it easier to use tables of values 196 AMESet 4 2 User Manual References 1 Blackburn J F G Reethof and J L Shearer Fluid Power Control 1960 New York Technology Press of M I T and Wiley 197 Appendix A 198 AMESet 4 2 User Manual INDEX A in Apre cpm 165 Activity Inde e d oy ai A edu diente e obl ieee Sas ote aia 96 Wald Dies vise dan d e axe did dup a mE 18 97 98 180 Add Cate SOY Scare bade Bien aa dto Benet rape etai Semaine an pre OR qo AER kx 150 ela Roo DC seirene rian A reap rents Eats mi Ss auti atit ees 152 PASE DIAG loops wos rs aie tron doi od een aue Ce ee uis do we E A T ood ut car eL 8 PV ONCE APER Siac hese ok irae Bie ae he So oe te Poe eh EDS Es Ste 129 AMELEEX CON a osi beet bg Pees Gee At aera ote oh Dod ad tee bean des depa 92 159 Subinodec EE E esos oer here ad Geek nes Same S qoum are nae mr 94 Tute OEC adem ceed at eto ade duke d wx urbe meine sudo oerte eal 94 Using to set parameters xoa me REX A eS EOS eee ees 92 AMBELbSxicondialog DOK 2142543 45 2 A Raices hat RR Q
57. 8 would have a discontinuity in its second derivative This is a relatively mild discontinuity and it is marginal as to whether special precautions should be taken for this Generally speaking e itis essential to take special precautions if states or their first derivatives are discontinuous e ifthere is a discontinuity in the third or higher derivative of a state no special precautions are necessary e fora discontinuous second derivative of a state it is wise but not nor mally essential to take special precautions For this example you will try both approaches 54 AMESet 4 2 User Manual 3 4 2 Submodel with no discontinuity handling You will first create a prime mover submodel without any discontinuity handling 1 Start AMESet select the prime mover icon from the Mechanical library and choose the submodel PM000 in the submodel list Note the following information about this submodel Figure 3 21 Calculation function Never called Call to the calculation function CO Always C When printing PM000 is a very simple submodel It is so simple that there is no need for a cal culation function at all Ticking the Never radio button ensures AMESim will never attempt to call the calculation function 2 Since you DO want AMESim to call our calculation function tick the A ways radio button Figure 3 22 You do want the calculation function called Call ta the calculation Function C Slane Never C When printing
58. A ace Bate 26 RELEASE OPUOM tl le Ba EE nip Mr AR 145 REMOVE CACC OLY A hw ie Ae e We et deux E e d 151 Remove componi 12d had dro S ded tl Soldes uh dace Roa a 153 INC DIACS iit cette em eRe a cordi Bae cda M petis der a pde 142 Reserved places for user code ioc e Certe en x e ex bv eos e a RR PUR 48 Residual of constraint variable s eL p be de Skew Se Ce peus 14 jede ci SIE LUDE eur las nd oe dora os cad aod ea a 178 179 202 AMESet 4 2 User Manual Restore BackUp iia wees Se ee eet wes AR 139 S SUD M OTT TTPr crue ire ata EN 137 Scala ahd ATTY S a e 19 SI Systerti OF UNIS A A AAA AA A 21 Simulation program SIEUCIULe OL A AAA A AE AA 5 Standard integer parameters ooo oommmooooooooorr eee ee eee ee bene ees 181 Stopping a simulation from a submodel 0 0 0 0 ccc eee eee 52 Submodel BID TP ICT EM 143 Descanse FC 49 Extracting equations outside 22 02 2225 leu Rr VER ERA da RU e eee 123 Po m 129 Name conventions ii pde e E DEP oda et RAG ok eed eee ee etos 32 Submodel Billet s ido deii pen etate a ult base awe ded dunque eg een dep ee 161 Submogel mentira RP xS SAS di bie EAM A aU 155 Submodels Bionic OP CIC TEILE 185 They do not do the integration 0 0 0 0 ccc rr 50 T Pea WMG Sone cee ths osi pana acea uUo e xc LI E totor 124 Texbparatietefs s tires deb odii ur bata Gk aci sr Pt As ero Do Ea e dtr ir dad 23 184 EDES ON duce 2 4 b
59. AMESet IMAGINE Copyright IMAGINE S A 1995 2004 AMESim is the registered trademark of IMAGINE S A AMESet is the registered trademark of IMAGINE S A ADAMS is a registered United States trademark of Mechanical Dynamics Incorpo rated ADAMSJ Solver M and ADAMS View M are trademarks of Mechanical Dynamics Incorporated MATLAB and SIMULINK are registered trademarks of the Math Works Inc Netscape and Netscape Navigator are registered trademarks of Netscape Communi cations Corporation in the United States and other countries Netscape s logos and Netscape product and service names are also trademarks of Netscape Communications Corporation which may be registered in other countries PostScript is a trademark of Adobe Systems Inc UNIX is a registered trademark in the United States and other countries exclusively licensed by X Open Company Ltd Windows Windows NT Windows 2000 Windows XP and Visual C are regis tered trademarks of the Microsoft Corporation The GNU Compiler Collection GCC is a product of the Free Software Foundation See the GNU General Public License terms and conditions for copying distribution and modification in the license file X windows is a trademark of the Massachusetts Institute of Technology All other product names are trademarks or registered trademarks of their respective companies Table of Chapter 1 1 1 1 2 1 21 1 2 2 1 2 3 1 2 4 1 3 Chapter 2 2 1 22 2
60. AMESet has put a factor in to convert to radians This enables us to think in SI units in AMESet but have the convenience of common units Also in the generated code is a call to the submodel function crank6_ Think of one line macros as a slightly more complex version of duplicate variables If we get a few other calls between the one line macro and crank6_ we may break an algebraic loop However it is not enough in the current case Step 14 Take the transformer ratio which is internal variable number 2 and modify as follows Figure 4 66 A multi line macro k ak internal variable 2 A Internal variable settings Variable generalities Setting Type of variable multi line macro Variable can be plotted True Variable details Setting Value Title transformer ratio Unit m Variable name tfratia Arguments theta Dimension What is a multi line macro In simple terms it is like a one line macro but with the possibility of more than one line of code You can also call any function you have access to including the full range of AMESim utility functions Instead of an Expression field there is an Argument field In this field you give a list of variables on which the multi line macro depends referenced by their names and separated by blanks and or commas Restrictions are the same as with one line macros 124 AMESet 4 2 User Manual Step 15 Take the linear velocity which is port 2 variable 1 and modify as
61. Alphabetic list Functions Used in submodels Technical bulletins k Signal Control and Observers Alphabetic list E utilities Eo Functions used in submodels de x ze You can also get information on AMESim utility functions that you can use in your submodels As an example if you wish to use the utility dlimit you can get a description of it as in Figure 5 13 Figure 5 13 On line help for dlimit Utility name dlimit Purpose Limits an input signal to a specified range Description This utility is a double double precision function used to limit an input signal to a value within a specified range function handles transition between limited and unlimited states as a diszcontinuity Fortran ff call prototype double precision dlimit external dlimit double precision sig lower upper integer reg If you are writing a lot of AMESim submodels you can probably save yourself a lot of time in the long term by browsing through these utilities See Figure 5 14 164 AMESet 4 2 User Manual Figure 5 14 Selecting utilities for on line documentation Utilities for AMESim Submodels When you write a number of AMESim submodels you will find that certain physical phenomena occur repeatedly This gives rise to a need to implement calculations for these phenomena It vould certainly be very inefficient to have to recode every time they were used and hence AMESim provides a library of utilities that you can call
62. C lt lt lt lt lt lt lt lt lt lt lt lt End of Calculation Executable Statements 126 AMESet 4 2 User Manual Step 20 Compile and debug the submodel Take your system containing the crank and replace CRANK5 with CRANK6 and verify the algebraic loop disappears We can now see how the multi line macro and two one line macros are treated like submodels avoiding the algebraic loop FP Sesion the state variables y calculated by the integrator to the appropriate variables v v 5 y0 j fhe state variable fom the integrator I Call submodel calculation subroutine in the order that ensures the input requirements of each submodel are satisfied pmWO0 n The one line macro for x only uses the y state variable which isv i v 4 cl D coscv 5 1 7453290925199 43 3e DL e rtr U 11 0 c1 0 c1 U simirse 5 1 745329251 981338072 emiv 5 1 745329251994 33e D21 v 6 crank macrol n amp v 5 rl cl J1 t ani The mult bne macro for fate only requires the state variable vO v 3 v 6 v 1 1 0471975511966 01 iir a ii wen n dami den amp mv 3 amp v T r2 MH The damper ve rev Hv vE 2013 17 1 Two one line macros associated with the damper crank den amp v 1 dov 2 amp v 5 edot amp v 8 rl c1 T1 det ME The crank v U 7 v 5 v 4 a Cne lme maoro for torg This gives some ideas of how macro variables can be used
63. DE i 10 A Ae 5 10 15 I D oo o M n What 1s happening is that the modeling assumption imply equations which further imply an infinite number of bounces before the ball comes to rest Numerically this is a disaster Which is the better submodel of the bouncing ball Almost certainly BL50 but BL51 1s certainly interesting Have you any ideas on how to overcome the problem 105 Chapter 4 Advanced examples 4 2 6 106 FL51 a floor submodel for BL51 The times at which the ball hits the ground will be very well picked out in plots if we run the simulation with Discontinuities printout enabled It would be instructive to pick out the points where a maximum height is reached FL51 will accept the one variable from BL51 which is a velocity We will integrate the velocity to compute the total distance traveled by the ball as follows gn v Note that the function v has a discontinuity in its first derivative If we use the following code we will pick out the points at which v changes sign as discontinuity points if disimp v ge 0 0d0 ic 1 then The sign of v is positive sdot else if disimp v lt 0 0d0 ic 2 then The sign of v is ve sdot endif Step 1 Load the old floor submodel FL50 Step 2 Save it as FL51 Step 3 Remove the output external variable and the displacement input leaving just the velocity input Remove all existing real parameters and internal variables
64. E core nia os a o arn ea ci ran t 141 Multi line macro variables RR RI RI Res 16 E xample oE US o sr n dnas te whit iaa ista ci aie a 125 126 N INE ERIT ia tia ira EE de cd a Bad T ees oe 135 O One line macro variables cee cee e 16 Conversion to SI units 0 0 ec e 124 EAMG OL USC wai cach eae Gee eee casa ia cds os aid 123 O db acd eri e uM vd LL eC oe Etat 163 ODER as tu aca d sie d tria Gh ene eck ee Aid uh art ane es Sine whe dd aq E 136 Ophion TH HUE edere boc cuts Apu es dene tench da iA Great wash eec Otto ose eres debo d 143 Ordinary differential equations naonnu naana cee ll 14 OUMU Got ra Bat dcn atu ded indic Ue en eee eke ea a ae ae wh hee at nee 7 P Parameter Mode Preview MW OOeHUHIe FI TOT edere eer amp ctm a al ad tati ats 92 PAL AIC CS Sa alah Red edP PARERE i a EA AE eu Md due 6 Pao eT ane tesa ds seg ei RID 141 E A fet A aa ciate te eB RM ie et a oe 143 DP Sashes ee eden oS Asse hig rth E es ies Te hn eg O Le ee 123 POS Bo arnt ere ae A ave ye gd Be Sd eae 6 Power Do notuse CHI CUESTA cog suck oie Ge oS IER WE RA eR Va mut a a eee 123 B God E O ae ca dos mente dt ato sa tdm t E Er eu eee 146 Preview submodel PAL ALO UCES x os sup Si lS I mda ip eee 155 Nanables sastre ad ek 156 Primary variable for duplicate o ooooooooooooron eens 15 ROPA A ta 137 Q A A A E ale 140 R Real patate IS errar Ea AS tad iaa 23 180 Reak Oies A A
65. ESet creates a submodel specification for you immediately Generate a submodel code skeleton AMESim submodels must be written either in the programming language Fortran 77 or C Of course you can write AMESim submodels without using AMESet However you can benefit a lot with the use of AMESet 1 The submodel specification the function call arguments and the declaration of variables can be made totally consistent 2 The description of the variables and parameters used in a submodel are included automatically in comment statements in the source code 3 A template for adding a description of submodel usage parameter setting and code revision 1s also included in the source code 4 A graphical environment for editing submodel details 1s provided 5 Youcan set component icon port type and location interactively and graphically 6 A great deal of time can be saved when creating new submodels Organization of this manual Chapter 2 AMESim submodels This chapter describes the nomenclature used for AMESim submodels and how the code of a submodel is structured Chapter 3 Getting started This chapter shows you how to create your own AMESim submodels and icons by presenting a series of tutorial examples Before reading this Chapter you should read Chapter 2 Chapter 4 Going Further You should read it after Chapter 3 It gives a further examples on the use of AMESet Chapter 5 Reference Guide for AMESet This chapter
66. F77 One is called once only at the start of a simulation run and will be referred to as the initialization routine The other will be called many times and will be called the calculation routine In addition if the submodels uses multi line macro variables there will be one function for each multi line macro For a submodel called NAME both routines must be stored in a single source file which will be NAME c for a C file and NAME f for a F77 file In the initialization routine access is provided to the real integer and text parameter arrays and to all explicit state implicit state constraint and fixed variables The following activities may be performed in this routine e The real and integer parameters may be checked for valid values if you think this is important e The set values of explicit state implicit state constraint variables and fixed variables can be checked Ifthe minimum default and maximum values of explicit state implicit state constraint or fixed variables are the same the values cannot be set in the submodel Change parameters dialog box They will be set to the default value when the submodel is selected You may wish to reset this value in the initialization routine 25 Chapter 2 AMESim Submodels 2 21 2 22 26 e A file specified by a text parameter may be read and the values used in some way e Ifnecessary real and integer stores may have their values set These variables are the subject
67. If you make a telephone support call you may need to create this dialog box to provide information requested by the support team The AMESet toolbars The toolbars consist of buttons all of which are equivalent to a menu item of the menu bar In addition there is one pulldown menu File gt New or Ctrl N see page 135 File Open or Ctr O see page 136 File gt Save or Ctr S see page 136 Edit gt Cut or Ctr X see page 140 Edit gt Copy or Ctrl C see page 141 Edit gt Paste or Ctrl V see page 141 This 1s the 7rash Can see below Selection of the source code generated C or F77 Code gt Generate code see page 157 Code gt Edit code see page 157 Code gt Compile code see page 157 Submodel Preview submodel parameters see page 155 Submodel Preview submodel variables see page 156 Use of the Trash Can The Trash Can is a storage area were ports variables and parameters which have been subjected to Delete are stored See Figure 5 22 5 6 AMESet 4 2 User Manual I aS A Y pen Clase Trash Can Chrl4T When you click to right of the Trash Can you get a menu of two items Empty Trash Can Click here 1 Open Close Trash Can If the Trash Can dialog box is open it will be closed else it will be opened as shown in Figure 5 16 Figure 5 16 The Trash Can dialog box m Trash Can Ports l Ext vars Int wars Real parame Int params Text parame d
68. In other words it is not supplied as part of a standard AMESim product Selecting this item produces an Available User Submodels dialog box The best procedure is as follows Step 1 Adjust the path list if necessary using Options gt Path list Step 2 Select Edit gt List User Submodels AMESet 4 2 User Manual Figure 5 9 The Available User Submodels dialog box Component icon User submodel Remove submodel the Remove button o Just remove submodel entry ar all submodel s files becomes active If o you click on this Alles Cancel button a Remove User Submodel dialog box appears You can remove the submodel in two ways 1 Submodel entry The entry in submodels index is removed which makes it inaccessible in AMESim 2 All files This removes the entry in submodels index and also removes the specification spe file source c and or f file any backup bak files of these and any object o or obj files If you take the first option you can restore the submodel using File gt Open and locating and loading the spe file If you take the second option the files really are deleted 5 4 3 Options menu Options Icons Submodel Cc Path list Compilers settings Color preferences AME Set Preferences Path List Select this to change the AMESim path list The functionality is precisely the same as in AMESim 143 Chapter 5 Reference Guide for AMESet Figure 5 10 The
69. Note there is a third possibility call the calculation function only When print ing This is useful when there are only information only variables 3 Setthe number of real parameters to 3 and set their titles units variable names and minimum default and maximum values as suggested in the following ta ble Variable name tau tstart Min le 6 1e6 55 56 Chapter 3 Getting Started Below is what you should have for the first real parameter Figure 3 23 First real parameter Parameter details Setting final speed Unit rev min Variable name omegal Minimum expected fixed value 5000 Default fed value 1500 Maximum expected fised value 5000 4 Specify that there is one external variable on port 1 with the characteristics shown in Figure 3 23 Figure 3 24 The external variable of PM50 External variables Internal variables Real port 1 external variable 1 External variable settings Variable generalities Setting Type of variable basic variable Input output status output Varable can be plotted True R AU Variable details Setting Title prime mover speed Unit rey min V ariable name omega Dimension 1 5 For the submodel brief description use see Figure 3 24 prime mover with start up characteristics 6 There is one important difference between PM50 and RACK50 PM50 requires access to time This can be achieved by clicking on the ch
70. Path List dialog box E Path List The path iz used for finding AME make AMElcons submodels index You can either pick the libraries an the right or add a directory using the text field and browse button below Path list should contain at least AME path Current path list Available categories AME Standard AME Sim library kh arousselamesin submodels Hydraulic AME libhedr Hydraulic Component Design FAME Hydraulic Resistance HAME libh 4 Add user defined path Add Add to path ist W Update categories Cancel Ze Remove Browse Compiler settings If you select this item you get a dialog box as shown below Figure 5 11 The Compiler Settings dialog box Compilers Settings El ES Command line for DEBUG compilations a 4M Ecc DEBUG bat Default Fortran Compiler Command line for RELEASE compilation 4M EF RELEASE bat Default Command line for DEBUG compilations 4M Ef DEBLIG bat Default amp C Campiler Command line for RELEASE compilation 4M Ecc RELEASE bat Default Cancel Ze 144 AMESet 4 2 User Manual Using Windows If the GCC compiler is selected as default instead of Figure 5 11 you will get the following Figure 5 12 The Compiler settings for GCC 5 Compilers Settings HE C Compiler Command line for RELEASE compilation ET Ecc RELEASE
71. UE ae eae 93 AMESet bd m x rU l AMESim Inte Stator bb dada ardor a dadas 50 DOM PlOCess wae moda eed Od m uude d OS dard Re s ducite o dO E HIRE Gane an l7 AMESim node Piles im Icon Tolder se E ae Seba ok LEGER AUS AG Saw eae eee ese 132 Piles 3n submodel Tolder s 12 eoe dci todo ERR dat eek 132 SS eoram adieu cotta m eee assu asa i erat ee a 131 C C lanpuabe SpeciliC TO dPUl6S 4 2 9351452 9 3 CX Se A acp E Ron o d 50 C alealatofiaccurde y IETT eut ts Big qe SER a MEHR SER RR RR RR eR es 48 Calculation function Called AWAS x cae AA dara patate Hue ee sr seeds 55 Called NOVELS adea aw oid brut detis x oda Lid arena da pied ne oa Meee en 55 Calculation functions subroutines o 25 Callculation function Called when PINS E AAA 55 OAS CAC M 163 Category icon amp cauDEga ACT 77 Cale Ory ICONS ia EA Ba ae SUR qe e A GI ater ARE RR RE we 133 Check State mella acide dca ech rd eon gister eS 51 CAOS ote winders ap SV d debug i SERIALS Iu DC EIE ews eee 140 COS 6 lb asiste dE P ieee he ag Pu a iy ei ped qug meiste 163 Code Calut ONS maras Ac mares dar ee eae Bes 48 Editors ten ch ERE RP ESSET bee TRUE ES ns eee ed apu a 147 InitfaltZdt oH y rd edad qs Red eir wR 48 MEDE 33 tuseide A i at dana Baa anaes 157 hos CT O eae Re Behe eS nde een A ee 157 Code editor MG sites las eve eta eve eee se eae Ok ey ay aa ee i he etn Beas A 141 MOMO nose dapi qood SL Se E ae teg arte ae awh ae Batre arte holte ie late Ee Xl crure rent 142
72. ake frequent use of Parameter Preview to be sure you are really getting what you intended 181 Chapter 5 Reference Guide for AMESet There are two fields to set 1 Configure enumeration To set or edit Configure enumeration net sel Bl this click on the B button in the Value field The Configure Enumeration dialog box appears Figure 5 26 The Configure Enumeration dialog box 3 Configure Enumeration E x Enumeration list hor Add Remove t amp Cancel Options gt gt There is a list of text strings which can be set to anything reasonably Embed ded blanks are allowed Four buttons allow you to edit the list Add Click on this button to add a list item It is added at the bottom Fill the text string Embedded blanks are al lowed j It depends Remove Select an item in the list and click on an this button to remove it f Select an item in the list and click on this button to move it one place up the list 3 Select an item in the list and click on this button to move it one place own the list If you select an item in the enumeration list and then click on the Options but ton you get an expanded dialog box This is used to selectively hide or show real parameters text parameters and other integer parameters when this enu meration value is set The following figure show the submodel UDAO associ ated with the icon 182 AMESet 4 2 User Manual Figure 5 27 The expanded Configu
73. alues which give a pressure drop across the check valve corresponding to the opening value i e dp 0 If this happens variations in pressure due to integrator noise can open and close the valve By reducing the integrator tolerance a cure can often be obtained but the code above adopts a different approach The quantity hys is a small pressure drop e g 0 00001 bar The trick here 1s to break the normal rules Constructing a table for the two states we have ic 1 condition for being in the condition for leaving region region logi dp ge 0 0d0 ap lt mnys 00 dp 1t 0 0do p gt hys The conditions in the second column are exclusive and exhaustive but those in the third column are not In addition the conditions in the third column are not the opposite to those in the second column Techniques like this can be very useful but naturally great care in coding and testing are necessary 4 3 A submodel using duplicate variables Objectives e To see how duplicate variables can be used to break algebraic loops e To gain some understanding of the AMESim sort process Step 1 Click on the icon shown in the Mechanical E category and select the existing submodel RL02 3B Step 2 File Save as and specify RL50 Step 3 Examine all the external variables You will find that on port 2 the first external variable 1s a state variable 112 AMESet 4 2 User Manual Figure 4 57 External variable is an explicit state
74. an click on the button Bl in the column and you will get a dialog box for selecting the unit as in Figure 5 25 It is a difference This is a boolean field which becomes available only when the real parameter has a unit set to either a pressure bar Pa barA or a temperature degC degF Set this field to True when the parameter is either a pressure drop or a temperature difference Leave it to False its default value otherwise This characteristics is used in AMESim when preferred units are required so that absolute units are replaced by relative ones or the opposite If the parameter is a difference and an offset is needed for the unit conversion then this offset will be ignored Variable name Click on the column Value and type in a name for the real parameter This name will be used in the submodel code Minimum expected fixed value Default fixed value and Maximum expected fixed value These characteristics are assigned by clicking on the column Value If the three values are identical the real parameter will not appear in AMESim and it will not be possible to change its value AMESet 4 2 User Manual Setting the characteristics of an integer parameter There are two ways to select an integer parameter 1 Inthe left part of the main menu expand the Integer parameters tree structure in the Type column until you Integer parameter 1 see the integer parameter you want Pob E 2 Click on it 5 renis de
75. ange submodel icon 2 Create the floor icon Do not forget to add the style of the single linear shaft port and to specify its po sition Here is a suggestion Step 5 Verify that the category exists and the two icons are in it Step 6 Set suitable colors for the new o mm zT category using Options gt Color preferences Creating the submodel BL50 for the bouncing ball How will the submodel work We have already decided that there are three exter nal variables associated with the single port We will work in SI units and give the variables obvious titles To summarize we have as our port 1 variables 1 explicit state velocity of ball m s 2 explicit state displacement of ball m 3 basic variable input external force on ball N Note the order of the variables The port of the icon was set to type Ishaft Nor mally one of the variables on such a port is a force in N The others will be one of the following combinations AMESet 4 2 User Manual Looe 1 NEAL S LAE 2 LE ME 3 wee 1 m s rie E displacement m acceleration m s s If a new submodel with linear shaft port is going to connect to an existing AMESim model with an Ishaft port it is important to adhere to this order Thus velocity comes before displacement Are there any real parameters Clearly the mass of the ball m must be a real parameter The acceleration due the gravity g could be another However the value is un
76. ange the two ic values selecting the other branch e Note that the first call at the start of the run and the call immediately af ter a restart has flag 0 In the previous example and in some other ex ample in this chapter this fact is important However in this example it is not necessary to use the discontinuity variable flag Discontinuities involve changing from one regime mode or state to another Each regime has its own set of continuous equations It is of the greatest importance that the conditions must be defined with great care In the present example the AMESet 4 2 User Manual conditions are Y ge YO y lt y0 Note we could have used conditions Y gt YO y le y0 and these would have worked equally well However if we had used y ge y0 y le y0 there would have been a lot of trouble This is because these conditions are not exclusive they overlap If we tried the conditions y gt y0 y lt y0 there would also be trouble because the condition is not exhaustive The condition where y y0 is not covered The important thing to remember is the conditions must not overlap and they must cover all possibilities Below is an example where there are three possibilities if disimp x le xmin ic 1 then else if disimp x ge xmax ic 2 then else if disimp x gt xmin and x lt xmax ic 3 then endif the code for each of the three branches being omitted Provided xmin lt xmax
77. ank e to show its capacity for creating algebraic loops e to use one line and multi line macro variables to improve it 116 AMESet 4 2 User Manual There is in the Mechanical library a crank icon and an associated submodel CRANKO This tutorial example follows the historical evolution of this submodel The diagram above shows the geometry of the crank The radius of the crank is R and the length of the connecting rod is L Figure 4 59 Geometry of the crank A little bit of elementary trigonometry gives X Rcos 0 4 AL Z R sin 0 X varies with the angle and we have LZRSXSL R We introduce an offset c X ZL R Rcos 0 4L Z R sin 0 ZL R with x the displacement at port 2 so that 0 lt x lt 2R This gives us the basic equation with which we will work We introduce the external variables for a 2 port submodel Figure 4 60 External variables of the crank a rey min 117 Chapter 4 Advanced examples 118 In addition we clearly need 0 as an internal variable We can now start to write equations OS y ot c XZL4R Reos 0 amp AL Z R sin 0 Z L R gg Zofsin o 1 eos JL Z R sin 0 and since for our ideal crank wT Fv we have pa w but we do have a problem when v 0 so there is an alternative form T ZFRsin 1 ao VL Z R sin 0 Note that the crank is an example of a transformer converting between rotary and linear motion We could introduc
78. ariables e Assien the state variables yC calculated by the integrator to the appropriate variables v l ve 5 ut01 4 The state variable from the integrator e Call submodels in the order that ensures the input requirements of each submodel are satisfied The one line macro for x only uses the pmOOD Cards a state variable which is v 5 vL4 cllOdecostvl5 1 45529251994 s4e 02 2qrtir1101 r1101 cibLo sciLo l sinteL5 1 1 d5329251994 sse 02 siniv 5 1 745329251994 3386 0255 P The mult line macro for tfratio WL crankb macro amp n amp wC5 ri cl Jil only requires the state variable v 5 yOOO_ an The one line macro for v uses tfratio vL31 v 61 vE11 1 0471975511966e 01 rich is vi damO00 amp n 24131 24071 r20 7 The damper eee rM de 1 de lt 7 Two one line macros associated with the damper crankb ten 24111 204121 20251 amp dotLOl 22161 r1 cl J1 The crank LO vlol eL21 lt amp One line macro for torq 17 Chapter 2 AMESim Submodels 2 12 Fixed variables This category of variable is the simplest Its name fixed variable is rather a contradiction They are fixed in the sense that they retain the same value throughout the simulation They are variables in the sense that you can set them to any reasonable value You can also stop the simulation run reset the value and then continue the run with the new
79. ariables they are either outputs inputs inputs with de fault or input unused AMESim insists that all variables have titles units and a dimension If they are explicit state implicit state constraint or fixed variables they also have special values to be used at the start of the simulation In the case of a fixed variable the value will stay the same throughout the simulation For an implicit state or a constraint variable the value is used as a starting value for an iterative process For explicit state variables it is the initial value to be used at the start of the integration Four values are associated with this special value of a fixed explicit state implicit state or constraint variable aminimum value adefault value amaximum value and e the actual value set When you select a submodel the actual value is set to the default value for all explicit state implicit state constraint and fixed variables Normally you can change this value in the Change Parameters popup The minimum and maximum values are for guidance only and it is possible to set values outside of this range 20 2 16 AMESet 4 2 User Manual However a submodel writer can set the minimum default and maximum values of an explicit state implicit state constraint fixed variable to be the same AMESim takes this as a signal not to display the initial value on the Change Parameters popup By this device the submodel writer can force a particular valu
80. ase FF code f Debug Advanced Cancel E Click on the button Debug in the Object type group box and click on OK Compile your submodel by clicking on the button or by selecting he Code gt Compile code menu item 2 In AMESim operate the Options menu If it is ME Options View Parameters nter not ticked already select Debug compilation Path list Submodel alias list Preferred units Debug compilation Current drawing settings Color preferences AMESim preferences 3 Create a very simple model in AMESim that uses your submodel and save it this will produce a C file associated with this model Note that if you save your model as NAME ame then the C file will be called NAME c 4 Doaquick run in AMESim to ensure all the data files are written 5 Start this executable from your debugger 5 8 Summary of variable assignments The following two tables summarize how variables are assigned or checked in the submodel initialization and calculation function or subroutine To avoid use of s the code is presented in F77 186 AMESet 4 2 User Manual Type of variable Example of code in initialization Comment function subroutine Basic variable Normally you do not write any code AMESet generates that is an input code to set these to their with default default value You could change the values but not normally necessary Explicit state if x gt xmax then
81. at the derivative of theta is omega The angle theta could then be calculated from the angular velocity omega by the AMESim integrator This would involve setting up the internal variable as follows Figure 3 12 Internal variable Variable generalities setting Type af variable explicit state Variable details Selling Variable name theta Variable dernvative name dtheta Dimension 1 Minimum expected initial value 1000 Default initial value O Maxinum expected initial value 1000 However this would be inefficient because you would be using 2 state varl ables when only one is needed This is the reason why we define theta as a basic variable The unit can be directly typed in or it can be chosen in the list below This list 1s obtained by clicking on the button B to the right of the Value field Figure 3 13 Selecting a unit using the Unit Chooser z fluid bulk modulus see hyd preu pressure Fe fluid kinematic viscosity E frequency a Er geometrical angle PPM fey H geometrical area H geometrical distances p degree Find 39 Chapter 3 Getting Started e AMESet can create code in Fortran 77 F77 or in C Since F77 is the most restrictive of these languages in terms of variable names AMESet uses the F77 name restrictions on variable names Hence names must e be of 12 characters or less the strict standard says 6 but normally 12 is accepted consist of either alphabet
82. ate an icon for the new category Remove category To be able to remove a category you must have write permission for the appropriate xbm and ico files to do the removal and write permission for the appropriate AMElcons file to modify it there must be no component icons in the category 151 Chapter 5 Reference Guide for AMESet 1 Select Icons P Remove category The Remove Category dialog box appears Figure 5 71 Removing a Category Fl Remove Category lx Select the category you want bo remove Mechanical r Remove icons files ico bm Cancel E 2 Select the category you want to remove e Check the box Remove icons files if you want to remove also the files of the icon ico xbm Add component Step 1 Create a new component 1 Use Icons f Add component The dialog box shown in Figure 5 1 is displayed Figure 5 1 Adding a New Component Icon E Design Component Icon Draw icon cor Ho icon specified Load bitmap 114 Select icon M ame Description Parent category Hydraulic pneumatic and electrical lines Cancel 2 Fill in the Name Description and Parent category fields to give the necessary information on your new icon Step 2 Specify an icon for the new component There are 3 different ways to assign an icon Draw a new icon Click on the Draw icon button to produce the con Designer Design the icon and set its ports plea
83. ate and like v 45 v 7 for a reversed sign duplicate Sometimes we would like very much more complex assignments than this and the two macro variables provide this facility The one line macro variable is as its name suggests limited to a one line assignment only The assignment involves other suitable variables real parameters and real stores of the submodel time and pi T Here is an example of code generated by AMESim to implement a one line macro v 12 v 23 v 56 v 78 1 7027648993 0 One line macros are very useful but they make submodels difficult to debug Use them only when there is a strong reason for doing so Usually this is to break an algebraic loop The next variable is a heavy weight version of the one line macro Multi line macro variables The multi line macro is an extension of the one line macro It is used when you need to break up a submodel because it creates algebraic loops It works like a one line macro except that you write the associated code in as many lines as you need It is actually a double function and is stored in the file of the submodel code It can call other functions such as AMESim utilities or user made functions AMESet 4 2 User Manual When a multi line macro variable is declared only its arguments must be entered These arguments are chosen from the list of the submodel variables AMESet writes the skeleton of the associated function automatically in the submodel code This
84. ated this will allow you to know its index of activity inan AMESim model For more details on the index of activity facility please refer to the Chapter 8 Activity index in the AMESim manual An activity variable is defined by a physical type e R dissipation 2 14 AMESet 4 2 User Manual e C capacitance e I inertia a physical domain e hydraulic e mechanical e electrical e thermal e magnetic e electric and a suffix which is used to generate the name for the power variable associated with the activity When an activity variable is declared some extra code is automatically added by AMESet at the end of the submodel code For more details on this topic please refer to the Chapter 8 Activity index in the AMESim manual Scalars and arrays AMESim uses the term array to mean a collection of two or more related quantities regarded as a single object Scalars are simply single quantities but can be regarded as arrays of dimension one 1 Many AMESim libraries contain no arrays at all We illustrate with an example from the hydraulic library which contains many submodels with arrays of variables In the simple submodel of pipe HL000 it is assumed that a single representative value of pressure can be used Variations in pressure with position within the pipe are ignored This is referred to as the lumped parameter approach Under many circumstances it is perfectly acceptable However if the pipe is long variations i
85. ble 1 o 3 External variable 2 i External variable 3 AK Delete E Internal variables 1 Insert new H Real parameters z Integer parameters de Cut Submodel requirements i Copy Submodel requires time Pr Paste e Submodel requires discontini tE Convert unit to 51 4 Move down Step 3 Set the number of real parameters to 1 Define it as follows Title mass of ball Variable name mass Min 0 001 Max 10 The definition of the variables and parameters is now complete You do not need time or the discontinuity flag You are already using SI units and so the status of the Convert to SI units check box is irrelevant Hence you just have to unselect it and you are ready to save the submodel Submodel requirements Submodel requires time Submodel requires discontinuities flag Convert unit ta 51 Call ta the calculation function v Always O Never C When printing 80 AMESet 4 2 User Manual Step 4 Set the submodel brief description as shown below Figure 4 39 Brief description e Bouncing pa Change icon P Brief description AMESet tutorial bouncing ball Step 5 Save the submodel as BL50 Step 6 Do a preview of Parameter mode Simulation mode and External variables as a check that all has been done well Step 7 Edit the code to complete the submodel 1 Define the outputs in the Calculation Function Executable Statements section as follows C
86. both the initialization calculation routines and from multi line macros Their main feature is they retain their values between calls To declared stores A 1 Select Real stores or Integer stores Ple gj al r 2 Edit the Numbers field directly or using the spin jussu eee kh g box arrows Note that there must be an integer store for each activity variable When you introduce an activity variable AMESim increments the number of integer stores When you remove an activity variable AMESim decrements the number of integer stores 174 AMESet 4 2 User Manual reserved for these variables Do not try to use them for any other purpose If there are N activity variables the last N integer stores are Setting the submodel requirements 5 6 2 Figure 5 23 Submodel requirements Submodel requirements Submodel requires time Submodel requires discontinuities flag Convert unit ta 51 Call to the calculation Function f Always C Never C when printing You can indicate your submodel requires time discontinuity flag or unit conversions by putting a tick mark in the corresponding check box You can change the way the submodel calculation function will be called by AMESim e Always is the default setting and is convenient in most cases e Ifthe calculation function is empty you should click on the Never button This will result in shorter simulation times when this submod
87. cate rdam n amp v 3 amp v 6 amp v 5 12 ap Rotary damper This is a simple v 2 v 6 M duplicate associa fed with RDM WOOO np Rotary merta ril En amp v 2 amp v U amp dot U amp v 1 amp v 4 rl 15 The important thing is the duplicate variables are taken out of the parent submodels and become submodels in their own right AMESim includes the duplicate variables with the submodels into a calling sequence Note that The reversed sign duplicate is called before its parent submodel and several other submodels are called between them This is the feature that makes duplicates useful The simple duplicate associated with RDAMO is called after its parent submodel It is not useful in this system but could be very useful in other systems Step 7 Change RL02 to RL50 Go to Parameter mode and reload the code generated by AMESim into an editor Note that when AMESim Creating a simulation program for your system regenerated the code it Number of states 1 indicated there was an Number of implicits 1 implicit variable Your new submodel certainly Algebraic loop did not declare an implicit state or a constraint The only possible way this variable is created 1s by an implicit or algebraic loop 115 Chapter 4 Advanced examples When you examine the code created by AMESim you will find the code is more complex Previously the LSODA integrator was use
88. cated very precisely with discontinuity handling even with a coarse communication interval To determine these points without discontinuity handling you must set a very small communication interval Figure 4 44 The displacement of the ball 1 FLS50 1 displacement of impacting object m y O 20 40 5 SQ 100 Time s Increase the damping coefficient in the floor icon to 10 N m s and run the simulation for at least 20 seconds You will find that there are a finite number of bounces and that eventually the ball comes to rest It is much easier to identify the individual bounces when there is discontinuity handling You can save results from one simulation and load them back after performing another simulation You will find that by zooming in you can see a difference between the results with and without discontinuity handling If you prefer plot the displacement subtracted from 10 m to get the height of the ball above the floor Use of an enumeration integer parameter 90 FL50 in its present state uses a standard integer parameter It is also possible to use an enumeration integer parameter It is easy to convert from standard to enumeration Step 1 If necessary reload FL50 into AMESet Step 2 Select the integer parameter and modify it to make a suitable enumeration integer parameter Do this in the following stages AMESet 4 2 User Manual 1 Change the Type of Parameter field to enu meration Setting Type o
89. cations will be lost Continue anyway 139 Chapter 5 Reference Guide for AMESet 5 4 2 140 Last opened files list The File menu displays the last opened files list You can use the AMESet Preferences to indicate the number of last opened files you want to display Close 1 PAME Simy 2 ttenalsubmadels F LBU spe e PAME Simy 2 O submodels Fea01 spe 3 F AMESIm v4 2 O tutorial submodelsBL50 spe 4 CAS FTP DE submodels FLBU spe Use File Close if you want AMESet to close the active submodel If the file is out of date AMESet will ask you if you want to compile it before closing it Quit Use File Quit if you want to terminate the AMESet session If any submodels have been changed without saving you will be asked if you want to save them Edit menu The first eight items operate on a selected or highlighted object This may be a port external variable internal variable real parameter integer parameter or text parameter For Copy Paste the source and destination objects must be of the same type with the single exception that you can Copy Paste between internal and external variables For a selected port the only operations that are allowed are Move up and Move down Cut d 3 A Edit Options Icons Submodel Code Cut bes Copy Ctrl C Paste Delete Del Insert new Ing Trash Lan Move up Ctrl Up Move down Chl D own PA Eind Ctrl F Replace Etrl H Goto
90. code Variable residual name This characteristics is only available for external variables the type of which 1s implicit state or constraint Click on the column Value and type in a name for the residual associated with the external variable This name will be used in the submodel code Residual unit This characteristics is only available for external variables the type of which 1s implicit state or constraint Click on the column Value and type in the unit of the residual associated with the external variable Alternatively you can click on the button E in the column and you will get a dialog box for selecting the unit as in Figure 5 25 Setting the characteristics of an internal variable 178 There are two ways to select an internal variable l In the left part of the main menu expand the 4 Internal variables tree structure in the Type column until you Intemal variable 1 see the internal variable you want NEZ Internal variable 2 Click on it Or In the right part of the main window click on the nternal variables tab Adjust the internal variable number by intemal variable 2 l using the arrows on the spin box External variables Internal variables In order to define an internal variable the following information must be given Internal variable generalities l Type of variable It is chosen in a list you get by clicking in basic variable v the column labeled Value The default typ
91. con i ES Tiles Build Fath List Select None Update Path List Select All Submodel Filter C Variables Parameters v Bath Title Filter nn Case Sensitive Exact Match Generate Note there are two tabs Titles Build Titles is for showing the results of an AMELexicon analysis Build is for defining an analysis Initially there is no completed analysis and hence the Titles tab is insensitive The Build Tab for AMELexicon The analysis to be performed is defined under the Build tab To define an analysis follow these steps Step 1 Set the path list A list of directories or folders of AMESim nodes is displayed each with a check box This is based on your current path list The task is to check the boxes of the nodes you are interested in The analysis will only be applied to the AMESim nodes that are checked The function of the Select None and Select All buttons is obvious If you do not like the current path list use Options Path list to adjust it and then click on Update Path List 160 Step 2 Step 3 AMESet 4 2 User Manual Set the filters There are three Submodel Filter Title filter Unit filter Submodel Filter This specifies the submodels you want the analysis to apply to The wild cards any string including null and any character may be used A further refinement is to specify whether you want the analysis to ap ply only to Variables o
92. contains detailed AMESet 4 2 User Manual descriptions of the facilities available in AMESet It is assumed that the reader of this chapter already has some experience of using AMESet e g by doing the tutorial examples in Chapters 3 and 4 Chapter 1 Introduction AMESet 4 2 User Manual Chapter 2 AMESim Submodels 2 1 2 2 Introduction Read this chapter if you are going to produce your own submodels for AMESim It describes the nomenclature used for AMESim submodels and how the code of a submodel is structured You must understand these concepts before you attempt the tutorial examples of chapter 3 The structure of an AMESim simulation program Figure 2 1 The structure of the code generated by AMESim INTEGRATOR Control Function Submodel 2 Submodel M Submodel 1 When you perform a simulation using AMESim computer code is produced which is specific for the engineering system you have displayed in front of you At the core of AMESim is an integration algorithm which advances the solution through time This integration algorithm calls the submodels which are associated with the components of the system as shown in Figure 2 1 These submodels may have been selected by AMESim automatically or selected manually by you In either case there will be computer code which implements the mathematical equations on which the submodel is based The order in which the submodels are called is not normally th
93. culation subrou tine or function 6 C Set all submodel outputs below C dx C theta C gt gt gt gt gt gt gt gt gt gt gt gt Calculation Function Executable Statements C lt lt lt lt lt lt lt lt lt lt lt lt End of Calculation Executable Statements Here assignments are made for the outputs of the submodel AMESet tells which variables have to be set Submodel description Note the lines of code which are near the beginning of the file they are similar to the following ones which are in Fortran C kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk C TITLE C REVISIONS C C kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkxkk It is intended that you e Modify this template if it is already filled with information on the sub model from which you create the current submodel This is the case for RACK50 which was made from RACKOO 49 Chapter 3 Getting Started e Complete this template if it is empty as shown above This happens when you create a submodel without starting from an existing one These lines give a description of the submodel you are currently constructing AMESim integrator It is worth mentioning a small point which does sometimes cause confusion to beginners It is not the job of the submodel to do the integration There is a central integration algorithm for doing this Thus you do not make an assignment in the calculation code for the
94. d and now it is the DASSL integrator Stripping irrelevant lines of code the structure is as follows Assign the state variables v calculated by the integra tor to the appropriate variables v v 0 y 0 m v 2 2 y 1 el JI is fhe explicit state and pii is a constraint Infroduced i by AMENm fo resolve fhe algebraic loop Call submodel in the order that ensures the input requirements of each submodel are satisfied t000 n Call fo rotary meria uses Infegrafor estimate viaj for forgue well amp ny Pd produced bp damper P 1150 c amp n amp v 3 amp v 2 amp v 0 amp dot 0 amp v 1 amp v 4 rl 11 E Rotary damper produces ds own estimate vif which is y 7 probably different rdam amp n amp v 3 amp v 6 amp v 5 12 2 v 6 a This is fhe simple duplicate associated with RDA delta Li v 3 v 1 viz and vro are fhe same A This is he error and fhe DALAL integrator must fey fo make X zero Remember AMESim uses the submodel as the basic unit with which it works It never looks inside the submodel Without the special constraint variable introduced by AMESim it was impossible to call rl30 or rdam0_ but this solution adds complexity and the original RL02 is better Duplicate variables one line macros and multi line macros are submodels in their own right 4 4 A submodel of an ideal crank Objectives e to create a simple submodel of a ideal cr
95. d deseo ione bodies aaa oe av UR E PR Ra d 184 AD TUS IA TOS NR IER TORRE A LITERATUR 184 Text EV DO oam baden Gm d e e C a e ETE Got dee ee te ee Ceo i sue 25 184 Unde nieder Se sie m a Se SURES aded Sh Boote ib p CERE he 184 Limes a submmodel HDD sereis Dei eR RP AR MR Peek o cue eoe ur dex dom Bet A 29 Tune as submogelinpur xs ra EI AR asa 155 AEE EEE ERSCHEINEN M EE E E E ES NE EE 161 LOOIDA CCP POR ECT PRIUS es A a T EAE 166 Tools MENE 24 ied dtr dae n AN EREN dec ge E a E E dom a 159 U MAUR goena dep EP bed Sel A aoe Ws Sachs UR an mn a ae eS 161 Units SUMAS os sore uS A ieee awe 155 Units of external and internal variables 0 0 0 0 ccc cece nee 21 Updated ate COLICS x d tune ue SU ea eee aate a WOE OT WMS ee Queue e depen 142 B moni Tr 155 V NY ATONE ETC a ip Lise E ae ac E ed UCET 6 Chameine ne Orden 3156 sa e ey eden E Sir eae aed e odia Rio dur 80 Comnplete classtiIGallon 24 0 tok ach dom o tpe adel pide edd x RUP og REP We 20 LECO UVES cite ula Bey cade ie ey oe tee enone ee Bae baaa e 9 View external variables c verit met he we ce Pacha dioec ra e i irn 142 203 Index W Windows menu 204 AMECustom 4 2 User Manual Reporting Bugs and using the Hotline Service AMECustom is a large piece of software containing many hundreds of thousands of lines of code With software of this size it is inevitable that it contains some bugs Nat urally we hope you do not encounter any of these but if you use AMECustom e
96. deas on fluid properties you have the opportunity to install your own properties There are two template submodels which are stored in the tu torial submodels directory of the AMESim system directory FP50 and FP51 and the idea is to copy one or both of them to your local working area and use AMESet to insert your equations This means the density the bulk modulus and the viscos ity of this fluid submodel will be calculated by your own functions In its original form FP50 is set up with one integer parameter index of hydraulic fluid The idea is you write your own rhoatp bmatp and muatp functions In this appendix an example of the use of FP50 is given New Fluid Properties mathematical model We will assume we want to create a fluid with the following characteristics Density varies with the current pressure according to the formula p p 1 axP b x P See Ref 1 where 0 is the density at atmospheric pressure a and b are two coefficients and P is the current pressure in Pa e Bulk modulus is an iso thermal value which is defined from the density as fol lows p poo itP a bxP dp dP a 2xbxP e Absolute viscosity is assumed to be constant and equal to 5 cP 191 Appendix A Creating the new FP50 submodel Using this mathematical model you can now create the corresponding submodel First start AMESet and use File Open and browse for FP50 spe in the tuto rial submodels directory of the AMESim system dir
97. del code by clicking on e then click on in order to edit this code Below is an example of the code generated in C The next sec tion 3 3 Comments on the code generated by AMESet gives more details on the content of the following code Please note that the code is edited in the AMESet fallback editor which is the current default editor If you wish to use another editor please refer to the para graph 5 4 3 Options menu AMESet preferences in the Editors section 41 Chapter 3 Getting Started In C Submodel RACK50 skeleton created by AME Submodel editing utility jeu 27 mars 09 16 00 2003 include lt math h gt include lt stdio h gt include lt stdlib h gt include ameutils h EEE SS ckckckock oko TITLE RACK50 DESCRIPTION This submodel of a rack and pinion converts a linear velocity vl in m s port 1 into an angular velocity w2 in rev min port2 and a torque t2 in Nm port 2 into a linear force in N port 1 f1 w2 vl radius S I units f1 t2 radius S I units where radius is the transformation ratio set by the user which corresponds to the primitive radius of the pinion A rack displacement in mm x is calculated by integrating the linear velocity v1 PARAMETER SETTINGS The transformation ratio radius must be different from zero However a negative value will be accepted This can be used to reverse the sign of the rotary motion DATE OF CREATION AUTHOR 26 02 1999 R
98. e Leave it to False its default value otherwise This characteristics is used in AMESim when preferred units are required so that absolute units are replaced by relative ones or the opposite If the variable is a difference and an offset is needed for the unit conversion then this offset will be ignored Variable name This characteristics is common for all the types of external variables except for the type duplicate variable Click on the column Value and type in a name for the external variable This name will be used in the submodel code Dimension This characteristics is common for all the types of external variables except for the types duplicate variable and one line macro Click on the column Value and type in a dimension for the external variable Minimum expected value Default value and Maximum expected value These characteristics are available for external variables the type of which is explicit state implicit state constraint or fixed variable They are assigned by clicking on the column Value If the three values are identical the external 177 Chapter 5 Reference Guide for AMESet variable will not appear in AMESim and it will not be possible to change its value Variable derivative name This characteristics is only available for external variables the type of which is explicit state Click on the column Value and type in a name for the derivative of the external variable This name will be used in the submodel
99. e The shortcut is CtrI S The facility is also available by clicking on the icon in the tool bar The source generated will be of type C or F77 corresponding to the source type currently set Note that you must have the appropriate write permission to save the submodel in this way This prevents you from overwriting the supplied AMESim library submodels If the submodel is a new one the Save facility behaves as Save as AMESet 4 2 User Manual The traffic lights The traffic light indicates if the submodel is in a fit state to save 99 If the traffic light is green the setup is complete 3090 If the traffic light is red the setup is not complete or is wrong The setup can be complete and not totally wrong but some settings may not relevant or could be improved This will not prevent the submodel from being saved but it is not totally satisfactory In these cases the traffic light will be orange Save as Select this item if you want AMESet to save your submodel under a new name Picos Rigi eet eer ete as Please enter the submodel name You are asked to define the name echo This must be unique i e not used by any other submodels or Cancel supercomponents Step 2 Select an AMESim node where it is to be stored Naturally you must have write permission Browse for Folder Ix Selecta directory H Desktop E E My Computer E 3H Floppy A Hc System C HE Data D Eg E peg Home Prod o
100. e always to be used or set the initial value in the initialization section of the submodel code Units of external and internal variables Both external and internal variables have units If a quantity such as Reynolds number is dimensionless you must set its units to null The SI system of units has won widespread acceptance in the scientific community In simulation work use of these units has strong advantages and some disadvantages The problem is that some SI units are of a highly inappropriate size for general and simulation use We now consider some examples which illustrates these advantages and disadvantages and describe the AMESim solution Use of SI units in calculations removes the need for conversion factors Thus the flow rate Q in m s from an ideal pump of displacement D m rotating at rad s is O D0 but if O 1s in L s D in cm rev and O in rev min Do 60x10 SI Units eliminate conversion factors and in consequence eliminate a common source of error The disadvantage of the use of SI units in simulation is that they often lead to bad scaling of state variables This is particularly true in hydraulic applications In hydraulic systems pressures of the order of 107 Pa and flow rates of 10 m s are common but the fluid power engineer is much happier to refer to these as 100 bar and 6 L min respectively Similarly it is extremely inconvenient to measure the spool position in a servo valve in m It is better to
101. e v dot is used for the derivative and the residual On entry v dot is an estimate from the integrator for the derivative of v and has units m s s On exit it is a residual and has units N In this case the first version is clearly better There is only one small advantage of the second version This is that it can tolerate no problem the value M 0 Only use implicit states if there is a very good reason for doing so 13 Chapter 2 AMESim Submodels 2 10 Constraint variables 14 Figure 2 9 Constraint variables of the MAS000 submodel These are much rarer than explicit state variables but are sometimes useful A simple example is in the load submodel MAS000 This submodel was developed from MAS002 which computed the one dimension motion of a mass subject to two external forces see Figure 2 9 in addition to its weight For the purpose of this description we will simplify the situation and only consider the velocity and two external forces Using the notation in the figure the time derivative of the velocity at the right port v is given by jv F ZF Ot M The submodel works well under most circumstances but problems arise when the mass M becomes very small The simulation becomes slower and slower and eventually unacceptably slow It is interesting to note that as the denominator tends to zero so does the numerator This idea is implemented in MAS000 by adjusting v such that F ZF 0 This is done by declaring v
102. e Resa eave tava aes 16 3 Multi line macro variables 4 noel dd 16 Use of duplicate and macro variables 17 Iaxed variables ua sues mut ER AA 18 ACTI Vd ETIDIE S aora wot totus sieut SR UR rt etd 18 Scalars and Ama sia ia is A aae ere S 19 Complete classification of AMESim variableS 20 Units of external and internal variables ooooooo 21 Plot access to external and internal variables 23 Table of contents 2 18 Timeas a submodel pub AA 23 2 19 Real integer and text parameters 2 2 0 0 0 eee 23 2 20 Initialization and calculation routines 0 00 cee eee eee 25 2 21 Jal and Inte Bet SIOFCS o 453 Cn o puma serae Pore eae boca wae rn fes 26 2 22 IDUSCOHLIUIH OS A cett aant oat eae pet 26 2 23 Generation of code skeletons p oy od od brewed eee pees ears 29 Chapter Gettin Started suco iaa aaa 3l Sl o lerss r 4 anto AU Ad Shaan ad oh tials diet sta wats oe 31 Submodel name conventions losses 32 3 2 A rack and pinion submodel with calculation of angular position 32 3 3 Comments on the code generated by AMESet 48 Functions defined in the submodel code 48 Calculation ACCUlACy dac SOLE Re Ooch ope d a eR d ede da 48 User reserved places in submodel code 48 Submodel description esisi siase sisane eens 49 AMESim integrator nananana nna
103. e a transformer ratio as follows OE imc o JL ZR sin 0 so that we have T FT and v OT Step 1 In AMESet select the crank icon and request a new submodel Note that port 1 is a rotary port and port 2 a linear port Step 2 Define the external variables on port 1 as follows Variable 1 Variable 2 Type basic variable output basic variable input Title angular velocity at port 1 Note that just in time we remembered that the is reserved for time and hence we used torg AMESet would not have allowed us to save the submodel with a variable named f Step 3 Define the external variables on port 2 which is the linear port as follows AMESet 4 2 User Manual Variable 1 Variable 2 Variable 3 basic variable output basic variable output basic variable input velocity at port 2 displacement at port 2 Step 4 Define two internal variables as follows CEC IE CI E m m 1 e f ow he ow Step 5 Define two real parameters as follows Um om omo Dee me ono me 9 09 Note we use stroke rather than radius because this is a more usual engineering term The radius is clearly half the stroke We can still use the radius by introduc ing a real store Step 6 Specify 1 real store Ensure the Convert units to SI box is ticked 119 Chapter 4 Advanced examples Step 7 Save as CRANKS and generate the code Step 8 Edit the generated code as follows 1 In the check stat
104. e any conversion coefficients At the end of the executable statements the variables are converted back to their original units Next close the editor File Close for the fallback editor and compile the code by clicking on the button e A dialog box similar to the one below will appear indicating if the code is compiled properly Figure 3 16 Compiling RACK50 Submodel Compilation Al ES Compiling HCEBU submodel E compiler Terminated DEBUG Messages Imagine 55 Submodels Windows NT compilation batch File This batch file is to automate the compile procedure for submodels or other uservritten C files using the Microsoft Visual C compiler Will compile the following file RACKSO c Command line warning D4002 ignoring unknown option 0 p HALKBU c HALKBL c 188 warning 24101 loop unreferenced local variable HALKBL c 185 warming 24101 log unreferenced local variable Submodel build completed Step 1 Test your new submodel l 46 Start AMESim and build the small model below in order to test your new sub model Figure 3 17 The new submodel in AMESim A piece wise linear torque profile is applied to the rack and the angular position will respond to this AMESet 4 2 User Manual 2 In Submodel mode select the submodels and in Parameter mode assign them the following non default parameters ecco 3 Runa simulation for 4 seconds with a communication interval of 0 01 s
105. e distance and in a finite time If no such device is incorporated the piston will still be brought to rest over a finite distance and in a finite time due to deformation of the parts involved in the collision Modeling of this situation is possible and extremely useful for detailed design of hydraulic jacks However the transient behavior would be extremely rapid and complex Use of a hydraulic jack submodel incorporating these features in general hydraulic simulation is unnecessary and might lead to unacceptable run times For general purposes in the hydraulic jack submodel the assumption is made that at the limits of its travel the jack comes instantaneously to rest This is an example of a discontinuity A discontinuity is characterized by a physical quantity AMESet 4 2 User Manual jumping from one value to another instantaneously In this example the physical quantity is the piston velocity Submodels incorporating discontinuities in physical quantities are quite rare However there are related phenomena that are more common A simple example occurs in control systems that include saturation elements There is an input x and an output y The output is limited to the range x Sy Sx otherwise y x A X typical example is shown graphically in Figure 2 13 The graph of y against x 1s continuous However the derivative of y is discontinuous at two points also shown in Figure 2 13 This function has a discontinuity in its first de
106. e is basic variable basic variable explicit state implicit state constraint fed variable multi line macro activity variable 2 AMESet 4 2 User Manual Variable can be plotted This characteristics is only Tie available for internal variables of type basic variable fixed variable or multi line macro It is chosen in a list you get by clicking in the column labeled Value It is either True or False The default state is True Internal variable details l Title Click on the column Value and type in a title for the internal variable This title will appear in AMESim when you will use the submodel Unit Click on the column Value and type in the unit of the internal variable Alternatively you can click on the button B in the column and you will get a dialog box for selecting the unit as in Figure 5 25 It is a difference This is a boolean field which becomes available only when the internal variable has a unit set to either a pressure bar Pa barA ora temperature degC degF Set this field to True when the variable is either a pressure drop or a temperature difference Leave it to False its default value otherwise This characteristics is used in AMESim when preferred units are required so that absolute units are replaced by relative ones or the opposite If the variable is a difference and an offset is needed for the unit conversion then this offset will be ignored Variable name
107. e same as the order in which the corresponding components were added to the sketch The submodels are sorted into an order that is more efficient from a computational point of view We will return to this subject after some concepts are introduced Chapter 2 AMESim Submodels 2 3 2 4 The nomenclature of AMESim submodels will now be described Variables and parameters During a simulation some quantities change with time Typical examples are the pressure in a pipe and the rotary speed of a load These quantities are called variables Sometimes in a particular simulation they are constant but since in principle they could vary with time they are still called variables Other quantities are always fixed during a simulation run These are called parameters and these quantities normally indicate a size or dimension of a component Examples are the diameter of a pipe and mass of a load Ports and external variables Figure 2 2 Port numbers of an icon 2 34 T The icons of which the AMESim sketch of the system is built are connected together at special points on the boundaries of the icon These points are called ports There are some icons which do not have any ports but these are rare Ports are numbered in a special way When the icon is in the form when it was originally selected the ports are numbered from the bottom left hand corner counterclockwise around the icon In Figure 2 2 the numbering of the port of the displaceme
108. e velocity is not used in SPROOORT However it has to be there otherwise it would not connect to a large number of other submodels It is the convention that velocity comes before displacement which comes before acceleration The following are typical mechanical submodels which we might hope to connect with the spring Figure 2 8 Typical variables on a linear shaft port The one on the left would not connect with SPROOORT but the other two would If SPROORT had only the displacement and not the velocity it would not connect with any of them 11 Chapter 2 AMESim Submodels 2 9 2 9 1 12 Internal variables can be basic variables Remember there is no concept of input output with a internal variable but a basic internal variable behaves like an output in that it must be assigned explicitly State Variables State variables are explicit or implicit In all cases there must be an initial value also called a starting value for the state variable State variables are not computed directly by submodels They are computed by the integrator A job of the submodel that is associated with the state is to directly or indirectly define a value of the derivative of the state Explicit and implicit state variables differ solely in the way this assignment is made e For explicit states a direct assignment is made e For implicit states a quantity called a residual is defined The integrator tries to make this quantity as small as possib
109. eck box labeled Submodel requires time As we will not deal with discontinuities for the time being ensure that the check box Submodel requires discontinuity flag is not ticked AMESet 4 2 User Manual 8 Inthis example it is definitely not worth converting to SI units so ensure that the check box Convert to SI Units is not ticked Figure 3 25 Submodel requirements PMOOO wu al A pmovyerdDl ee Change icon Brief description prime mover with startup characteristics Er Parks 2 E Part 1 external variables 1 rehaft Internal variables m c eal paramete TES Submodel requirements ubmodel requires time Submodel requires discantinuities flag onver unit bo S Call to the calculation Function v Always C Never C when printing 9 Now select File from the menu bar and then Save The dialog box below should appear and you can then type the name of your submodel Figure 3 26 Type the name of your submodel El Enter Name lx Flease enter the submodel name PM 50 OF Cancel 10 Generate the code skeleton by clicking on and edit the generated code with 57 Chapter 3 Getting Started In the calculation routine omega must be defined This involves inserting the following lines of code if t ge tstart then omega omegaf 1 exp t tstart tau else omega endif tstart omegaf 1 exp t tstart tau 1 Compile the submodel by click
110. eck sign of v if v ge 0 0d0 then ic 1 1 else ic 1 1 endif endif if ic 1 eq 1 then The sign of v is positive sdot v logi v lt 0 0d0 call disloc logi else The sign of v is ve sdot v logi v ge 0 0d0 call disloc logi endif 110 AMESet 4 2 User Manual Note that the code is slightly more complex and there are more opportunities for getting it wrong Only one integer store value is used instead of two but this is hardly worth the greater complexity In most cases it really is better to use disimp Why then do some users prefer to use disloc on occasions Here is an example of a section of code taken from the submodel of a check valve which employs hysteresis dp pin pout if flag eq O then if dp ge 0 0d0 then C C Check valve is open C ic 1 1 else C C Check valve is shut C ic 1 0 endif endif if ic 1 eq 1 then C C Check valve is open C qout dp k C C Check for check valve shutting C logi dp lt hys call disloc logi else C C Check valve is shut C qout 0 0dqd0 C C Check for check valve opening C logi dp gt hys call disloc logi endif The hydraulic check valve submodel on rare occasions chattered This means that it opened and closed rapidly which generated many discontinuities resulting in a slow simulation This can occur when the system tries to achieve a steady state 111 Chapter 4 Advanced examples with v
111. econd and plot the angular position of the pinion and its velocity You should get the following curves Figure 3 18 Angular position and velocity of the pinion 2 RACKS angular position degree Pu c 1 RAGKES 1 rotary velocity at part 2 rev min 0 2 3 4 Time 3 47 Chapter 3 Getting Started 3 3 Comments on the code generated by AMESet Functions defined in the submodel code The first thing to notice is that there are 2 Fortran subroutines or 2 C functions e The first is for initialization and is called once at the beginning of the simulation The second is for calculations and is called many times during the sim ulation Calculation accuracy All arithmetic is performed to double precision accuracy In F77 One consequence of this is that in F77 code you should always put real constants in double precision form 1 e 0 39d0 rather than 0 39 or 0 39e0 User reserved places in submodel code 48 There are six places in the code where you are invited to insert your own lines These start with lt lt lt lt and end with gt gt gt gt characters These insertion points are described below in Fortran l C gt gt gt gt gt gt gt gt gt gt gt gt Insert Private Code Here C lt lt lt lt lt lt lt lt lt lt lt lt End of Private Code The private parts section can be used for various purposes You could for in stance write a function or subroutine which is called by your subm
112. ectory Start AMESet and then select the file FP50 spe from your working area A display similar to that shown in Figure A 1 should appear Figure A 1 AMESet with FP50 loaded 8 File Edit Options Icons Submodel Code Tools Documentation Windows Help ml External variables Intema variables 4 port El estemal variable 1 Variable generalities FP50 9 99 elementaryhydraulicprops Change Icon Brief description simple specific Fluid properties i Ports 0 z Internal variables z Real parameters O VYanable details H Integer parameters 1 Submodel requirements Submodel requires time Submodel requires discontinuities flag I Convert unit to 51 Call ta the calculation function Always O Never when printing Note that an integer the fluid index is already defined but you need three param eters 00 a and b Declare them using the values as in Figure A 2 192 AMESet 4 2 User Manual Figure A 2 Values of the parameters External variables Internal variables Real parameters Parameter details Setting Title density at atmospheric pressure Unit ka m 3 Variable name density Minimum expected value Default value ab d aximum expected value 10000 External variables Internal variables Real parameters Parameter details Setting Title pressure coefficient Unit 1 Pa Var
113. een oot A ince ao Sere ake a Wee Be eee eee 5 E Bit COS Loses Moorea ea eared bor A tua ordei Ge amet al dE tae are 157 HC ANA MRNA A oh hk ee At oA el a tet cnt 140 Enumeration Confor ata a aio oed Sue ee ad ato si Be Seb PPM ELE 182 Hide SHOW 4 dide ege tet deste ect cbe tae Saint Y dot S EI peas dul Awan ences 183 Enumeration integer parameters IGS PIC MOINS ox o E Y e o ane 183 Explicit state variables uas oe cand ue es RE d he bad iR IN E Bee X s nee 12 200 AMESet 4 2 User Manual External variables Sie ou real AGA ate Daa a EUR Bw Pa wan ee eR 6 176 F TD STING HU isis acs te wha A E M aea am tw a hae a OD 135 Files associated with a submodel 0 00 ccc ee eee eens 52 y PC E EN O OEE AENT TENETE TEE 141 Fred vartable37 ir EA 18 Fluid Properties CT CANO VOUF O WIL c eco OUO etel isa 19 G Generaton of code skeleton 1 512 E ewes A PRA A he weed 29 157 RTO ih a a Sag eee aire ene cece a ta M DE dE MI re a dat 142 H ERC INS Pr P T ER 163 Helpon utility functions nexus Se XA As AR CREE USC PS PSA RR EE ERR RN SER 164 Hiding variables oan etre a eR HAC eoi iia s 23 HTML documentation Create HEEME SKGIG OD 5 1n ere rogato eeepc dran ts Ate Sedes 158 isi eL 158 View HTML documentation ser 158 I ICON dc cipes cus cce iU ME LUCR tto etia tlle t 154 DOOM GMI IET sols eM delati sd du e rtr EUR LL em e IN M RED 150 MPCS a ede red ance
114. el is used since its calculation function will not called by AMESim e Ifyou select When printing the calculation function is only called when new data is added by AMESim in the simulation result file Setting the characteristics of variables and pa rameters After declaring a variable or a parameter you must set its characteristics from the right part of the AMESet main window If you select a variable or a parameter you have just declared you will find that default characteristics are assigned to it Information is given on the current selected variable or parameter number as shown below internal variable 1 Note that there is a single traffic light next to each variable or parameter in the Misc column It necessary expand items in the list to show individual parameters or variable This works like the facility for the lights for the complete submodel see The traffic lights page 137 If it is orange or red you can get further information by expanding the Misc column or putting you pointer in the Misc column 175 Chapter 5 Reference Guide for AMESet Figure 5 24 Determining the cause of an error amp Titl Tithe must be set Real parameter 4 ger parameters 1 it parameters O Setting the characteristics of an external variable 176 There are two ways to select an external variable 1 In the left part of the main menu expand the tree structure in the 7ype column until you see the external
115. el or to assign an icon to the submodel which has no icon yet If you click on this button the dialog box shown in Figure 5 20 appears From there you get a list of the available categories and if you select one of these you will be able to choose an icon of the category you selected Figure 5 20 Selecting an icon for a submodel E icon Selection Ej Mechanical seve masse pork 7 mass_friction2port du Cancel An important point is that you only have access to the icons for which the number of ports and the port types are compatible with what you specified in the basic features see Declaring external variables page 173 169 Chapter 5 Reference Guide for AMESet Setting a brief description A field is at your disposal to type in a brief description for the submodel see figure below This field contains text which will be displayed when the submodel will be selected in AMESim Figure 5 21 Entering a brief description Brief description ideal linear spring with calculation of energy Right click menus associated with ports variables and parameters If you select a variable or parameter and you click on the mouse right button a menu similar to the one shown will appear x Delete Insert new Cut Copy Paste Move up buy Move down If you select any port and you click on the mouse right button a slightly different menu will appear Append new external va
116. ements section of the initialization function subroutine C gt gt gt gt gt gt gt gt gt gt gt gt Initialization Function Check Statements if L le stroke 2 then print Connecting rod length must be greater than stoke 2 error 2 endif C lt lt lt lt lt lt lt lt lt lt lt lt End of Initialization Check Statements if error eq 1 then 1 In the executable statements section of the initialization function subroutine C gt gt gt gt gt gt gt gt gt gt gt gt Initialization Function Executable Statements C Set crank radius c 1 stroke 2 C lt lt lt lt lt lt lt lt lt lt lt lt End of Initialization Executable Statements 2 In the declaration statements section of the calculation function subroutine C gt gt gt gt gt gt gt gt gt gt gt gt Extra Calculation Function Declarations Here double precision sint cost root C lt lt lt lt lt lt lt lt lt lt lt lt End of Extra Calculation declarations 3 In the executable statements of the calculation function subroutine gt gt gt gt gt gt gt gt gt gt gt gt Calculation Function Executable Statements Set common guantities sint sin theta cost cos theta root sqrt L L c 1 c 1 sint sint transformer ratio and hence the torque and linear velocity tfratio c 1 sint 1 0dO c 1 c 1 sint sint torg tfratio force vel tfratio omega Set linear displacement C 1 cost root L c
117. ent ex ample real stores references by c c2 etc c in the current example normal arithmetic operators like and also and for raised to the power be careful if your keyboard supports as in it 1s safer to use y parenthesis with their usual mathematical significance pi which is taken to be m simple mathematical function of one variable sin and cos in the current example t which is taken to be time Now we must define what we mean by an appropriate variable It is easier to say what variables are not allowed a variable cannot be defined in terms of itself basic variables which are outputs are not allowed duplicate variables are not allowed variables with dimension greater than are not allowed These rules appear to be somewhat arbitrary To understand why they exist it is interesting to see how the one line macro works If we saved CRANK6 in its present state and used it in a simulation the code generated by AMESim would included a line like 123 Chapter 4 Advanced examples c1 0 cos v 5 1 74532925199433e 02 sqrt r1 0 r1 0 c1 0 c1 0 sin v 5 1 7453292519933e 02 s1n v 5 1 745329251994338 02 el 01 costv 5 sgqrt ri 0 1 0 c1 0 c1 0 sin v 5 sin v 51 1t would have had exactly the same structure as the expression The difference 1s there because we asked for conversion to SI units The variable theta which corresponds to v 5 is in degrees
118. ep 1 Open the ball submodel BL50 Step 2 Set the number of internal variable to 1 set its type to activity variable and define it as follows O e e Physical type Variable name suffix mass This activity variable will be related to the inertial power of the ball As you introduce an activity variable you will find that the number of integer stores is incremented by 1 Step 3 Generate and examine the code 1 Examine the calculation function subroutine You will find that the power variable is a local variable declared as follows double precision powImass and the activity variable is actImass which is passed through the argument list There is also a special section added near the end of the code if isactivity eq 1 then Set the following power variables C powlmass C gt gt gt gt gt gt gt gt gt gt gt gt Activity Computation Statements E lt lt lt lt lt lt lt lt lt lt lt lt End of Activity Computation Statements Call setactivity ic 1 actImass powlmass BL50 n mechanical I endif Note the call to the function isactivity This is used to determine if the calcu lations are to be performed The call to setactivity processes the powlmass variable and produces the activity act mass Note that it uses an integer store 1 Check that the integer store is declared properly with dimension 1 97 Chapter 4 Advanced examples Step 4 Edit the submodel code In
119. es are in the direction of the arrow This means a positive velocity v and displacement y will be measured downwards and gravity will assist them A positive force F will oppose them It follows that the governing equations are lt 7 ot i JE Sm where m is the mass of the ball The force F excludes the force due to gravity and will be taken to be zero when the ball is free of the floor and non zero when in contact with the floor We are making assumptions but this is always the case in a 4 2 1 AMESet 4 2 User Manual modeling situation In particular we are ignoring air resistance which is reasonable since the speeds involved will be relatively small See the standard AMESim icon ports in Chapter 12 Facilities Available In Sketch Mode of the AMESim manual This convention is important and it is bad practice to introduce new types of port without good reason Bearing in mind the units on the ports we recommend you use linear shaft Ishaft ports You will construct a submodel 550 for the ball and FL50 for the floor However since none of the standard icons are suitable you must construct two new ones There are AMESim categories which store the icons needed for libraries supplied with the AMESim package You are not allowed to add you own icons to these However you can create one or more of your own categories in which you can store your own component icons You may have already created categories and component icon
120. everal times in the manual Ifyou use C do not use the function exit or abort Use AmeExit 1 instead Ifyou use F77 do not use the subroutine stop Use call famexit 1 instead Note there is one integer argument to these functions You normally set this to 1 The value 0 indicates a normal exit and any other value an abnormal exit 1 e on detecting an error Files associated with a submodel Note that for each submodel you create called NAME for instance there are three files associated with it The source file NAME f or NAME c The specification file NAME spe e The compiled version of the source NAME o or NAME obj 52 3 4 3 4 1 AMESet 4 2 User Manual Prime mover with start up characteristics Introduction The simplest prime mover submodel of the Mechanical library is PM000 which is a constant speed source There is only one external variable which is a fixed variable with title shaft speed and units rev min A typical graph of the shaft speed using the default parameters is shown below mE Figure 3 19 The constant speed prime mover 3 10 1 PM000 1 shaft speed rev min 1 50015 1 E 1 50010 1 50005 1 50000 1 49995 1 49990 1 43385 1 43380 O 0 02 0 04 0 06 0 08 01 Time z It would be interesting to develop a submodel which gave the start up characteristics of the prime mover Denoting the speed of the prime mover at time tby a simple model of the start up characteristics
121. f parameter enumeration gt Parameter details 2 Change the Title field to discontinuity handling 3 The Configure enumeration field is currently displays not set Click on the E button to create the Configure Enumeration dialog box shown in Figure 4 45 Figure 4 45 The Configure Enumeration dialog box Setting Title discontinuity handling Varable name mode Configure enumeration not set Bi iefaul umbo mL Enumeration list Far discontinuity handling Add Remove tl 3 Options gt gt 4 Itisnecessary to add two character strings that will take the place ofthe values 1 and 2 Click Enumeration list for discontinuity handling on the Add button twice 5 Enter the text strings active and inactive in the Text column e Inactive 6 Clicking on the Option button produces an expanded dialog box which offers the possibility of hiding parameters according to value is set for the enumera tion integer parameter However in this case this 1s not useful so click on the OK button Notice how the Parameter details have changed 91 Chapter 4 Advanced examples Figure 4 46 Parameter details for an enumeration integer parameter Parameter details Setting Title discontinuity handling Variable name mode Configure enumeration active Default value active The Default value has been set to the first string in Configure enum active the list which is active This can be
122. false respectively The definition of the array elements is as follows e ic 1 set to true if the object is in contact with the ground i e y 2y0 e ic 2 set to true if the object is NOT in contact with the ground 1 e y lt y0 Thus one will be set to 1 and the other to 0 Next we must define the function disimp Users of C have the advantage that there is a header file called ameutils h which is included in the code This defines the function disimp and a several hundred others For Fortran users if you declare a submodel as having discontinuities this function will always be declared as follows logical disimp external disimp The first argument of disimp is of type logical and the second integer and almost always it is an integer store variable The function does a great deal of work managing discontinuities for you The detail of this work is hidden and all you need worry about are the following e Make sure that AMESet knows that the submodel has discontinuities so that disimp is declared properly Make sure that the logical conditions which form the first argument to the function are exhaustive cover every possible case and exclusive have no overlap In C since the first argument is a pointer to type int it is necessary to declare two variables for the conditions int condi cond2 85 Chapter 4 Advanced examples 86 and set them Conds y gt y0 cond2 y lt y0 or even Cond y
123. formation to the left of point P using the smooth curve C2 This arrangement can be made to work very well but relies on cooperation between the integration algorithm and the submodels In practice messages must be sent between them so that submodels detect the discontinuity and inform the integrator 28 2 23 AMESet 4 2 User Manual The integrator informs the submodel when a restart is in progress so that various initialization can be done Generation of code skeletons AMESim submodels are written in either Fortran 77 or in C By constructing new icons and submodels you can greatly extent the capability of AMESim and customize it to the needs of your particular application Writing submodels is a fascinating and rewarding activity but can be difficult and time consuming To ease the process the AMESet AME Submodel editing tool provides facility to automate part of the code writing process In order that AMESim can use your submodel just like standard AMESim submodels you must tell AMESim what icons it is associated with what external and internal variables it has etc To do this you effectively fill in a form The AMESet utility provides you with this form and checks your inputs to ensure that they are reasonable and consistent When this process is complete AMESet will allow you to assign variable names to external and internal variables and optionally to real and integer parameters It will then generate a piece of code t
124. from your submodels On this page the most important are breifly described for a full list in alphabetic order please qo here Here are some important examples with the names af the corresponding utilities exit from the simulation from a submodel Amet xit written in C exit fram the simulation from a submodel famexit written in Fortran stick slip in linear motion inert linertl c linert2c stick slip in rotary motion rinert physical limitations on the range of a variable pressure rate of change in a compressible pcdunm pcdyn Fluid About Figure 5 15 About AMESet i AMESet Copyright 1996 2004 by IMAGINE 5 4 all nights reserved Software Information Version 4 2 0 September 2004 Platform windows MT 2000F Software configuration AME path FAMESim v4 2 0 Available libraries Standard AME Sin libran anne Hydraulic E libhydr Hydraulic Component Design AME ibhicd Hydraulic Resistance 5 ME libhr Contract number IMAGINE_SIT E Contact us Address IMAGINE 5 5 A rue Brison 42300 Roanne FRANCE e mail address Imaginec amesim com Phone number 33 4 7 23 60 3 international O4 77 23 60 30 France Technical suppor hatlineceamesim caom Web site http www amesim cam 165 Chapter 5 Reference Guide for AMESet 5 5 166 This gives a lot of information on the version of AMESet you are using and the libraries to which you have access
125. function can then be completed according to your needs At this point it is necessary to pause to see why duplicate and macro variables are useful Use of duplicate and macro variables What is the point of introducing duplicate and macro variables Previously we stated that AMESim sorted submodels into a special order We will qualify this statement by saying that AMESim gives to duplicate variables and macro variables the same status as a submodel This greatly reduces the chance of algebraic loops Remember you can look at the code generated by AMESim Ifthe system is NAME ame the generated source code is NAME c In Figure 2 5 is a section of code generated which has been edited slightly to remove lines of code not strictly relevant to the present topic Note the calls to the submodels and interspersed with the assignment of the duplicates and macro variables The example has been taken from Chapter 4 where it is discussed in detail Why not make all variables duplicates or macros so that AMESim would not sort submodels at all but solely equations Putting all or most of the equations into the submodel code has a lot of advantages It makes the model much more modular and much easier to debug You will be writing submodels soon Do not expect to always get them right first time AMESet actually restricts use of duplicate and macro variables to cases where there is potentially an advantage of using them Figure 2 10 Duplicate and macro v
126. g the arrows on the spin box E Text parameters jo be Text parameter 1 a Tent parameter 3 er parameters Text parameters text parameter 2 g In order to define a text parameter the following information must be given Text parameter generalities Text type It is chosen in a list you get by clicking in the column labeled Value The default type is undefined e Use input file if the text parameter specifies a data file that must be read when the simulation run e Use expression if it is a mathematical expression in term Value undefined gt undetined input file expression of some token s e g x that must be evaluated when the simulation runs e Use undefined for all other cases Parameter details 1 Title Click on the column Value and type in a title for the text parameter This title will appear in AMESim when you will use the submodel 2 Default value Click on the column Value and type in the text you want to assign If the Text type 1s input file you can use the button El to browse the default file instead of typing 1ts name and path 184 5 7 AMESet 4 2 User Manual Figure 5 28 Browsing for a data file Open Look in 4 Gearbox EN a exhaust data Files of type A files Cancel If the Text type is set to expression type an expression in terms of the specified tokens The expression will be checked for validity 3 Ifthe type is exp
127. ger parameters Text parameters i nteger stores is Aaal sharar H i Port 2 extemal Append new external variab 2 Delete Insert new Move up 4 Move down This is way of adding or removing ports 1 Next to the Ports entry in the Type column edit the value in the Number column Enter the number directly or use the arrows in the spin box E Forts If you increase the number ports are added at the end If you decrease the number ports are deleted from the end If you increase the number of ports and then increase them back to the original number you will find they are all there in undamaged condition Removing a port To remove a port 1 Right click on the port you want to remove of the Type list 2 Select Delete You are asked to confirm Deleted ports are put in the Trash Can 172 Ed r arc ze i H Port 1 external variables 3 l M Fort 2 external pa z Internal variables pu Real parameters z Integer parameters Append new external va gt Dele Insert new i Text parameters H nteger stores Move up i Heal stores 4 PIDE Moving a port To move a port up or down 1 Right click on the port you want to move A menu appears 2 Use the items Move up and Move down Note that is the submodel has already been associated with an icon the move may make the submodel incompatible with the icon In this case AMESet will remove the association Setting port
128. gravity Figure 4 42 The ball falls under gravity 1 BLSO 1 displacement of ball m SIO Liris 400 SD 200 100 O z 4 5 amp 10 Time s 4 2 3 Creating the floor submodel FL50 The submodel we will use for the floor will be called FZ50 It will effectively provide a force corresponding to a spring damper system This force will only apply if the displacement received from the ball exceeds a certain value 82 AMESet 4 2 User Manual Step 1 Create a new submodel associated with the floor icon Step 2 Specify 3 external variables on the single port and set them as follows Variable 1 Variable 2 Variable 3 basic variable basic variable input basic variable input output Title force provided by velocity of impacting displacement of floor object impacting object Remember the order is important Step 3 Set the number of real parameters to 3 and define them as follows displacement at spring rate between damping coefficient which impacting impacting objectand between impacting object hits floor floor object and floor es bw p p poo i Like all submodels the purpose in life of FL50 is to compute its outputs from its inputs There is only one output It is fext and the simplest way of defining fext is writing in Fortran 77 83 Chapter 4 Advanced examples 84 if y ge yO then C C The object is in contact with the floor C fext k y yO damp v else C
129. hat the number of integer stores is correctly dimensioned at 4 Step 4 Compile and save FL50 AMESet 4 2 User Manual Activity index computation in AMESim Open the AMESim model using BL50 and FL50 and do Tools f Check submodels in order to use the latest versions of these submodels The activity index calculations can be enabled from the Run parameters dialog box If you run a new simulation and then select the menu Tools Activity index an Activity Index List dialog box appears showing the results below As you can see the capacitive activity of the floor is 99 97 of the total activity of the model Figure 4 51 Look at the activity of the floor capacitance Select a results file activity af mechanical inertia mass 6 257 e 001 J FL5U 1 activity af mechanical dissipation damper 4 02803 H FL5U 1 activity af mechanical capacitance spring 1 625e 007 J E Format Time 20 2 C Fixed Floating Automatic update Plot 4 2 5 BL51 a submodel employing a coefficient of res titution Next you will construct two completely different submodels for the ball and floor based on different modeling assumptions These will be called BL5 and FL51 respectively The assumptions are when the ball hits the ground its velocity is reversed in sign and its mag nitude is multiplied by a constant factor less than one This factor is sometimes called the coefficient of restitution BL50 dealt with the displacement and vel
130. he submodel skeleton in Fortran 77 or C This will consist of the initialization and calculation functions or subroutines with their declarations In addition there will be extra functions if the submodel uses multi line macro variables The external and internal variables will be described in comment statements with their titles and units Similarly the real and integer parameters will be described The layout will be standardized so that the code will look the same regardless of who wrote the submodel Within the code skeleton are at least six insertion points where your enter lines of code for Private code section for own special purposes Initialization function or subroutine declaration statements Initialization function or subroutine checking statements Initialization function or subroutine executable statements Calculation function or subroutine declaration statements Calculation function or subroutine executable statements If in the course of development of the submodel you add or remove external or internal variables or real or integer parameters by rerunning AMESet the skeleton is regenerated keeping the statements you have added intact This facility has proved very popular with submodel writers as it removes much ofthe laborious activity allowing them to concentrate on the more creative aspects 29 Chapter 2 AMESim Submodels 30 AMESet 4 2 User Manual Chapter 3 Getting Started 3 1
131. iable name pcoett Minimum expected value 1 Default value 6 35e 010 Maximum expected value 1 External variables Internal variables Real parameters Title pressure squared coefficient Unit 1 Pa Pa Variable name pzcaetf Minimum expected value 1 Default value 1 132 018 Maximum expected value 1 Save your submodel create the C code skeleton and edit it You must now update the DESCRIPTION section of the submodel its PARAMETER SETTINGS sec tion and fill in the private code part the new text added is in bold gt gt gt gt gt gt gt gt gt gt gt gt Insert Private Code Here Global variables associated with the submodel parameters static double gdensity static double gpcoeff 193 Appendix A 194 static ifdef static double double delse static Hendif double gp2coeff _NO_ PROTO double rhoatp tcelsius p tcelsius ps double rhoatp double tcelsius double press double rho press rho p return rho Hifdef static double double delse static Hendif _NO_ PROTO double bmatp tcelsius p tcelsius p32 double bmatp double tcelsius double double press double bm press p bm l press gpcoeff gp2coeff press bm gpcoeff 2 gp2coeff press return bm ifdef static double double delse static Hendif _NO_ PROTO double muatp tcelsius p tcelsius p double mua
132. ic in disimp are left to the user in disloc The function disimp was written as a much easier to use replacement for disloc However many experienced AMESim submodel developers continued to use disloc because they felt they had more control and could employ a number of tricks which were impossible with disimp The rest of this section comprises a description of disloc It is suggested that if you are reading this chapter for the first time you skip the rest of this section The classic use of disloc has the following form if flag eq 0 then C C Integration has just started or restarted C Set value of ic 1 C if condition then ic 1 1 else ic 1 0 endif endif if ic 1 eq 1 then C C some statements here logi not condition call disloc logi else C C some other statements here C logi condition call disloc logi endif 109 Chapter 4 Advanced examples where logi is automatically declared ogical for F77 and type int for C and condition is replaced by something like in which case not condition will be replaced by not x le x0 or equivalently x gt xO0 It is useful to construct a table from these values as follows Condition for being in region Condition for leaving region Note that the same rules about an exhaustive and exclusive set of conditions that applied to disimp also apply to disloc if flag eq 0 then Integration has just started or restarted Ch
133. ical characters or digits e start with a letter Note There are some further restrictions due to reserved C and F77 keywords such as if else for call etc If you enter a 3299 wrong keyword you are informed with the red light in the upper right side of the interface or with an error message e The dimension must be left at 1 Dimensions greater than 1 indicate an array of variables This feature 1s useful on occasions but its use is not common 5 You can also get a preview ofthe Change Parameters and Variable List dialog boxes you would get in AMESim Click on the buttons Sl and le to get the previews shown in Figure 3 14 and Figure 3 15 respectively Figure 3 14 Parameter Mode Preview A AME Sim Parameter Mode Preview RACK 50 a External variables rack and pinion linear velocity input at part 1 wih angular position radius of the pinion Help Options gt gt 40 AMESet 4 2 User Manual Figure 3 15 Run Mode Preview 22 AMESim Hun Mode Preview Submodel RACK SO rack and pinion External variables linear velocity input at pork 1 with angular position null M linear velocity at part 1 null m s rotary velocity at port 2 null res rnin torque at port 2 null Mm displacement of the rack null mm angular position null degree 6 Select the programming language you want AMESet to use for cre ating the submodel code either C or Fortran M 7 Generate the submo
134. ick on External variable 3 and select Delete You can also select Cut The difference is that with Cut you can always Paste it after Alternatively 2 Edit the number of variables on Number port 1 to 2 Check that the two vari 5 Ports 1 ables left are what they should be Fort 1 extemal variables E zl shaft l T z External variable 1 Step 4 We want to move the displacement external variable to an internal variable This is done very easily 1 Highlight external variable 2 Check that you really have got the right one it is the displacement With the right button menu select Copy 2 Select Internal variable 1 3 With the right button menu select Paste the previous activity variable is over written by the displacement variable 4 Remove the second external variable as explained in Step 3 AMESet 4 2 User Manual Now we will consider the code for BL51 With the coefficient of restitution represented by coefr the most obvious way of coding this is as follows if y gt yo then Ball has hit the floor yo coefr v This 1s the most extreme form of discontinuity in which there are jump changes in the state variables It is almost guaranteed to cause severe problems and very likely complete failure in the integration algorithm It is common practice in simulation code to protect against this sort of abuse by not allowing a model to change state variables AMESim always gives access to a copy ofthe sta
135. ill find the list of the existing variables param eters and stores Select the item nternal variables and click on the column Number The current number of internal variable is 1 set it as 2 Figure 3 9 Adjusting the numer of internal variables E Internal variables E H nternal variable 1 Internal variable 2 4 Select the item nternal variable 2 and assign it the features shown in Figure 3 10 The new internal variable characteristics Figure 3 10 The new internal variable characteristics Variable generalities Setting Type of variable basic variable Variable can be plotted True Variable details Setting Title angular position Unit degree Variable name theta Dimension 1 At this point a few words of explanation are needed The variable type is chosen in a list of possible types Figure 3 11 Setting the type of variable Selling Type of variable basic variable gt Variable can be plotted basic variable E explicit state implicit state constraint fed variable multi line macro activity variable 38 AMESet 4 2 User Manual You select basic variable because the angular position can be obtained directly from the position of the rack and the radius of the pinion The angular position is explicitly defined by theta radius x 1s the linear position of the rack and radius is the radius of the pinion Another way of determining theta would be to use the fact th
136. ing on e and then test it with a suitable sys tem in AMESim The following test system is satisfactory Figure 3 27 Test system for PM50 Note that while you are doing this you can exit AMESet or leave it running Try it with various final speeds time constants and startup times You will probably find its performance is satisfactory despite the discontinuity Howev er ignoring discontinuities like this can create problems and often leads to longer simulation runs Enable run Statistics from the Run parameters see Fig ure 3 26 and perform a run making a note of e The time for the simulation The maximum step size used e The number of function evaluations The latter is the number of times each submodel is called 58 AMESet 4 2 User Manual Figure 3 28 Enable statistics Miscellaneous Statistics Use old final values I Monitor time Minimal discontinuity handling 3 4 3 Submodel with discontinuity handling Modification of the submodel specification To modify PM50 to handle the discontinuity properly restart AMESet if necessary and select the prime mover PM50 will appear as an existing submodel and you must select it to read in the current specification There are two changes to be made to the specification 1 Tick the check box Submodel requires discontinuity flag 2 Set the number of nteger stores to 1 Figure 3 29 Change submodel requirements PMB dd 99 pmovyerDl al Change icon
137. int is the standard integer parameter AMESet 4 2 User Manual Figure 4 48 The standard integer parameter in FL50 ae Type of parameter standard C NEN Title 1 for discontinuity handling 2 for ignore discontinuities Variable name mode Minimum expected value 1 Default value 1 Maximum expected value 2 1 Start AMELexicon using Tools gt AMELexi con The AMELexicon dialog box appears as eum shown in Figure 4 49 AS Figure 4 49 The AMELexicon dialog box AL AMELexicon 93 Chapter 4 Advanced examples 94 2 At the top is Path List which is constructed from your current path list Initially no items are Path List checked Check the 4ME item jv gus AME lba Under Submodel Filter is a This is a wild card indicating all submodels are to be searched Leave it like this but select the Pa t variables cu rameters radio button We want to search all the parameters of all the submodel in AME Under Title Filter enter the text dis continuity handling Tick the check Tile filter box Exact Match discontinuity handling Case Sensitive e Exact Match Submodel Filter x Click on Generate to create lists of parameter of submodels in AME contain ing the exact text discontinuity handling Figure 4 50 AMELexicon with lists generated AL AMELexicon El E Titles Build Yanable tithes 15 discontinuity handling 1 discontinuity hand
138. is wo 1 exp t T where is the final speed of the prime mover in rev min and 7 is a time constant in seconds You could have taken the angular speed in rad s so that everything was in SI units but the use of rev min does not introduce any unpleasant conversion factors The formula assumes the prime mover starts from rest at time 0 It might be useful to be able to modify this formula so that the prime mover could be started after some time delay If it starts at time t the equation becomes L t TA ND Gf 1 Zorn J for t t and w 0 otherwise start 53 Chapter 3 Getting Started There will still be a single variable but it will be of type basic variable instead of fixed variable In addition there will be three real parameters with the following titles and units e final speed rev min e time constant s e startup time s Figure 3 20 Prime mover with start up characteristic 3 1 PMB 1 prime mover speed rev min 10 1 5 0 25 Time amp A typical graph of against time is shown in Figure 3 19 It is clear that is a continuous function of time but its derivative is not discontinuity at time t 2 s If the prime mover were connected to a rotary spring as shown the discontinuity would be transferred to the spring submodel RSPROO The angular twist 0 calculated by the spring submodel is a state variable and would be used in defining its derivative Hence
139. is the responsibility of AMESim submodels to detect discontinuities and tell the AMESim integrator about them e When a discontinuity has been registered by a submodel with the integra tor the integrator will locate the discontinuity Imagine a ball released from rest above a floor The ball will bounce off the floor until it comes to rest This is a very familiar situation and it is a rich source of modeling details It is very instructive for modelers of all levels During the motion there are two distinct stages 1 the ball is moving freely under gravity 2 the ball is in contact with the floor The equations governing the motion of the ball in these two stages are quite different The times at which the ball comes in contact with the floor and leaves the floor are clearly discontinuity points We do not know in advance unless we solved the equations analytically the time at which the discontinuities occur You will construct two icons similar to those shown One icon represents the ball and the other the floor This figure K also shows that each icon has one port and shows the external variables for each of the two submodels that will be constructed For the ball submodel there are two output variables corresponding to y and v and one input variable corresponding to F The situation is reversed for the floor submodel All these variables have a direction associated with them With the AMESim sign convention positive quantiti
140. isplacement at which impacting object hits floor m y Nb elements 1 Restore Empty Trash Can E Note the 6 tabs for selecting ports various variable types and various parameter types You can select one or more items in the list and then e Drag and drop them onto a submodel Click on the Restore button which will attempt to put them back from whence they came If you feel the Trash Can has too much in it click on Empty Trash Can 2 Youcan also select Empty Trash Can in the Trash Can menu to do the same thing The AMESet main window This is the place where the submodel specifications are set It is split up into two parts as shown in Figure 5 17 To the left are shown the basic features of the submodel which are The icon associated with the submodel A brief description The number of ports with their types The number of variables and parameters with their status e The number of stores 167 Chapter 5 Reference Guide for AMESet 5 6 1 e The submodel requirements To the right are shown the characteristics of the selected variable or parameter which are for the variables The variable generalities type of variable plottability input output status The variable details title unit variable name dimension and for the parameters The parameter details title unit variable name Figure 5 17 The AMESet main window External variables Internal variable 4
141. ivity index in the floor submodel 98 Activity index computation in AMESim 00 99 4 2 5 BL51 a submodel employing a coefficient of restitution 99 4 2 6 FL51 afloor submodel for BL51 o oooooooooooooo 106 4 2 7 A final word on BL51 2 1 0 enn ne 107 42 5 USOS s id BS ate Shot Baa Re nace ha nee ae bes 109 4 3 A submodel using duplicate variablesS o oooooooo 112 4 4 A submodel ofan ideal crank 0 0 00 cee 117 45 Jane Submodels s isa iu Aa 129 4 6 Avoiding algebraic loops 0 0 00 teens 129 Chapter 5 Reference Guide for AMESet ee ewww eee 131 Sol iIBITOGUCH OTI a4 22 rides labs aci 131 diz JAMES it NOdGS estad IAS 131 5 3 Using the CaltccOryICONS camara EY dem ADU ee a 133 34 TheAMESe ment bat ou ics wold Ciel be REDE eee eee 134 Sel A miS sa dies bue ex REP TES 135 SAA Edt THES ied e dc Ped edat Sete ecu eee d Re bodies Segoe wet ated 140 349 Options Mens ia ER 22e a d tantisper Eden sonidos 143 Path E19 203 Aa 143 Compiler settings devas 144 Color prelerences alada 145 AMESEL PrelerenCes seer quce td erar p HE Pre oce s 146 S44 ICONS MEE uod neo Aa 150 S45 Submodel Me is beo bete ete t e ee deb em ied 155 34L0 Code TUE oa 5523 dd RC ode edo irons 157 5417 Documentation menu AA A 158 348 WOON AMC ei ree Coa e eden ebd de Soie deme aoe Beca dent 159 340 Windows Menu 2s eee a A ERES 163
142. le by varying both the state variable and its derivative Both external and internal variables may be state variables If an external variable is classified as an explicit or implicit state it is always an output All state variables have titles and units The units of the time derivative of the state can be derived from the units of the state by remembering that the simulation time always has the units second Implicit state variables are rare in AMESim It is in general far better to use explicit state variables Explicit state variables Almost all AMESim simulation runs involve solving differential equations This is because many submodels are based on differential equations For example most of the mass submodels use a differential equation of the form ov _ force Ot mass where v is velocity and is time We say that v is an explicit state variable In AMESim nomenclature we say that the velocity is an output of the submodel but strictly speaking the submodel only calculates the velocity indirectly What the submodel does calculate is the time derivative of the velocity dv dt as given in the formula above From this the integration algorithm calculates v 2 9 2 AMESet 4 2 User Manual Implicit state variables These have attributes which are a combination of explicit state and constraint variables which are described in the next section The distinctive characteristics are as follows The integrator gives the
143. likely to be set to anything other than 9 81 Hence for this exercise we will stick to one real parameter with title units minimum default and maximum values as follows 4 mass of ball ke 1 0e 3 0 1 0 5 Does the submodel generate discontinuities The answer is that it does not Discontinuities occur in the force generated by the floor and they will be dealt with there Step 1 Run AMESet select the ball icon from its category and select a new submodel Step 2 Set the number of external variables on port 1 as 3 and define the 3 variables Suggested variable fields are Port 1 variable 1 Port 1 variable 2 Port 1 variable 3 Variable type explicit states explicit state basic variable input ball Unit aie ti DIR Deme m Ra 0 Dmm 3 9 Da 9 9 o Dems x ow 79 Chapter 4 Advanced examples Note that these variables are in the correct order We must ask a question What happens if I get the order wrong Sooner or later you will do this and it is easy to correct 1 First AMESet will impose the rule outputs before inputs before inputs with default You have no choice 2 In the current example it is possible to get variables the wrong way round To correct this click on the appropriate external variable with the right button and select the item Move down or Move up Figure 4 38 Changing the order of external variables E Forts 1 Port 1 external variables 3 lshaft a External varia
144. ling 1 active O inactive J discontinuity handling for linear splines 0 inactive 1 active 2 discontinuity handling identifier 1 numerical hysteresis For discontinuity handling null Submodel list ctrl POME Fx401 Integer parameter 3 ctrl PAME FRAO Integer parameter 3 ctrl AME Fxra0l Integer parameter z ctrl fAME Fey ade Integer parameter z ctrl PAME FxYZAUI integer parameter z ctrl f4ME UDA Integer parameter 3 meca 4ME FORCOT Integer parameter 2 gt Print Submodel List 6 10 11 The parameter we want is the first one and it is used in 15 submodels Click on this and The Submodel list re constructs to show these 15 submodels Double click on FX401 and it is loaded into AMESet Locate integer parameter number 3 Right click on this parame ter and select Copy Close EXA01 or use the Windows menu to make FL50 the active submodel Right click on the integer parameter of FL50 and se lect Paste The new details appear AMESet 4 2 User Manual V ariable tithes discontinuity handling 1 d discontinuity handling Far Variable no ctrl PAME Fx401 Integer parameter 3 ctrl aME Fx4010 integer parameter 3 ctrl PAME Fe AC Integer parameter 2 ascifofx Change icon Brief description signal function of output defined by ASCII file E Integer parameters Integer parameter 1 pu Integer parameter 2 i Integer parameter 3 X Delete i Integer parameter 4 o
145. lve using the DASSL integrator Technically d a e s are classified by an integer known as the index of nil potency or simply index Algebraic loops generate index 1 d a e s which are the easiest to solve whereas the zero mass submodel MAS000 described in section 2 10 results in an index 2 problem which is significantly more difficult The infinite stiff spring submodel SPR is similar whereas the differentiator submodel D F00 gives rise to an index 1 problem To summarize there are two types of implicit variables e Implicit variables declared in submodels as constraints or implicit states These usually result in index 1 or 2 d a e s Constraints created by AMESim to resolve algebraic loops normally resulting in index 1 d a e s The ordinary differential solver used in AMESim is generally more reliable than the d a e solver However there is no point becoming pathological about d a e s The best advice for submodel writer is to seek to reduce the number of implicit variables rather than totally eliminate them This can be done by observing two rules 1 Introduce declared implicit states and constraint variables in submodels spar ingly and only when there is a genuine need Warn users in the text of the de scription section of the code of the problems that can arise using these submodels AMESet 4 2 User Manual 2 Construct all submodels in a way that minimizes the chances of algebraic loops with generated implicit variables T
146. ly the value a default value is used An example of submodel that uses an input with default is BHC11 in the HCD library This has external variables as follows Figure 2 5 The external variables of BHC11 d L min cm3 bar The submodel represents a hydraulic chamber At the 4 ports the inputs are a flow rate in L min and a volume in cm During normal usage we might want to connect a BHC port toport 1 of the HCD piston submodel B4P1 1 shown on the left but also to the hydraulic accumulator submodel HA000 shown on the right of Figure 2 6 AMESet 4 2 User Manual Figure 2 6 Submodels we want to connect to BHC11 jain bar L min cm3 bar The problem is that the accumulator HA000 does not supply a volume The solution was make all the volumes of BHC input with defaults Figure 2 5 the default being 0 0 cm The fourth type of input output status for a basic variable is input unused An example of this is SPROOORT Submodels ending with the letters RT are designed to be as fast as possible Currently there are few of them but the number will grow rapidly Extensive use is made of duplicate variables and macro variables They have to be constructed very carefully to avoid algebraic loops and input unused variables play a role in this Figure 2 7 The external variables of SPROOORT The external variables of SPROOORT look the same as all the other spring submodels but there is an important difference Th
147. m breaks the deadlock by making either the force or the velocity a special constraint variable and using a generalized Newton method to solve for it In Figure 4 63 it is the force but in your case it could be the velocity This can depend on the order in which you added the components to the sketch The system normally works OK with its algebraic loop but there can be a slight loss in speed and reliability Remember that state variables are calculated by the integrator and not by the submodels It follows that the crank angle 0 is available Hence the outputs on port 121 Chapter 4 Advanced examples 122 1 of CRANKS v and x can be calculated freely It follows that the input velocity for DAMO000 is known and there is no need for the algebraic loop at all Remember the following statement AMESim uses the submodel as the basic unit with which it works It never looks inside the submodel One possible solution is to split up the submodel into two or more parts To take this to an extreme we could build a supercomponent as follows Figure 4 64 Using the red library to build a crank theta trat y omesga trat torque F trat This ignores the displacement but even that could be calculated if really needed We could associate this with a crank icon We could even customize it with AMECustom to make it appear similar to CRANKS However AMESim provides another solution We would like to extract some of the equations from CRANK and
148. must create new icon before you attach the submodel to it Submodel menu Submodel Code Tools D Time required Discontinuity handling w Use Sl units a Preview parameters fe Preview variables Submodel requires time This and the next two items can be set to true ticked or false unticked The status can also be set using the Submodel requirements check boxes Submodel requires discontinuities flag Convert unit to 51 Submodel requirements Submodel requires time If Submode requires time is set to true the time variable t will be included in the calculation and multi line macro functions subroutines argument lists generated by AMESet Discontinuity handling flag If Discontinuity flag required 1s set to true the flag variable will be included in the calculation and multi line macro functions subroutines argument lists generated by AMESet Use SI units If Use SI units 1s set to true AMESet will convert real parameters and variables to SI units on entry to any functions subroutines and e convert them back to common units on exit Preview submodel parameters This shows you how the active submodel will look in the AMESim in the EN Change parameters dialog box The facility is also available by clicking on the button in the tool bar Use this facility frequently to check that what you are getting is really what you want 155 Chapter 5 Reference Guide for AMESet Figure 5 5
149. n Fatsnake H Egi Appli an Fatsnake P 1 52 Public on Fatsnake 7 3 Control Panel Print This item becomes active when a the source code of a submodel is displayed in the AMESet fallback editor in which case File Print produces a dialog box to enable you to print the source code 137 Chapter 5 Reference Guide for AMESet Using Windows Figure 5 7 The Windows Print dialog box See HP LaserJet 2200 Series PCL 6 an FATSNAKE EA LaserJet 4M PS 2 me ta HP LaserJet 200 PCL6 on FATSMAKE POF 995 A HP Lase y WebWorks Rasterizer selection Lurmentirage 138 AMESet 4 2 User Manual Using Unix Figure 5 8 The Unix Setup Printer dialog box ee E setup Printer Print destination f Print to printer imagel C Print to file Printer settings C Printin colorif available Printin grayscale A4 210x297 mm 5 26x11 7 inches Options C Print all Print first page first Print selection C Print last page first C Print range ili From page To page Humber of copies Restore backup When you create submodels it is not normal to get them all right at the first attempt Hence you continue to work on them and overwrite the old source and spe file with a new and hopefully better version creates one level of backup when this 1s done If you use File Restore backup you can restore this backup You are asked to confirm the request Last modifi
150. n a special checking section of the initialization routines between lines labeled 51 Chapter 3 Getting Started In F77 C gt gt gt gt gt gt gt gt gt gt gt gt Initialization Function Check Statements C lt lt lt lt lt lt lt lt lt lt lt lt End of Initialization Check Statements gt gt gt gt gt gt gt gt gt gt gt gt Initialization Function Check Statements lt lt lt lt lt lt lt lt lt lt lt lt End of Initialization Check Statements In the current submodel RACK50 the check statements come from RACK00 and can be updated A special variable named error is declared for you and initialized to 0 Ifyou want the program to be stopped when an unacceptable value is found you must set the local variable error to 2 e fitis just a warning set error to 1 After the section for checking the value is examined a message printed and if necessary the program is terminated Stopping a simulation from a submodel Note that in the C code you do not use the function exit to stop the simulation but rather the function AmeExit Similarly in Fortran you do not use stop but rather the subroutine famexit You could use exit or stop but the alternatives provided enable AMESim to terminate in a rather more graceful manner This is very important when your AMESim executable is interfaced with some other code such as with the Simulink interface We will repeat the following request s
151. n o d e solver How does MAS000 compare with MAS002 Often when the mass is very small compared with the forces it is spectacularly faster It can fail however and it is very easy to think of cases where this is guaranteed to happen Suppose we set constant values for the two forces as follows F 1000 F 2000 What value of v will make the residual zero Clearly this is not possible and if you try this example you will find that the d a e integrator gives up with an error message To summarize constraint variables of this type can be extremely useful but must be used sparingly and with suitable warnings for the user Note that when AMESim detects an algebraic loop it will alter the status of one or more ordinary variable to make it an constraint variable This will break the algebraic loop Duplicates one line and multi line macro variables These three types of variable are grouped together because they are great for avoiding algebraic loops They do this because the code that defines each of them takes on the status of a submodel in its own right and is independent of the submodel to which they belong Do not worry if you find this section a little confusing at first reading As you begin to develop your own submodels and your experience grows read this section again and it will become much clearer Duplicate variables Sometimes external variables are calculated as outputs on one port but they are also needed as o
152. n pressure with position become too important to ignore Under these circumstances a distributed parameter approach is used in which a series of pressure values are computed The submodel AL020 is a distributive parameter pipe submodel that has an array of 5 internal pressure nodes and an array of 5 internal flow rate nodes AII the pipe submodels HLOxx where xx is 10 or above are distributed parameter submodels with internal variables consisting of arrays of pressure and flow rate External variables can also be arrays although this is less common An obvious case where external array variables are useful is in mechanical submodels where two or three dimensional motion occurs In such cases arrays can be used to specify position coordinates and components of velocity These will be exchanged between components Remember that all external and internal variables are either scalars or arrays 19 Chapter 2 AMESim Submodels 2 15 Complete classification of AMESim variables AMESim variables have a number of classifications 1 they are either external or internal 11 they are either scalars or arrays 111 they are one of the following basic variables e explicit state variables e implicit state variables constraint variables duplicate variables simple or reversed sign one line macros e multi line macros fixed variables iv if they are internal variables they may be e activity variables v if they are external v
153. na eee nee 50 C language specific features 0 0 llle 50 Compilation flags for Fortran below Unix 0 51 Check statements rre navn estt a UR aco eode d a tia eect 5 Stopping a simulation from a submodel 52 Files associated with a submodel oooooooooooooo 52 3 4 Prime mover with start up characteristics o oooooooo oooo 53 SI Introducilotis souci oboe rl IL eee ab e beo e d 53 3 4 3 Submodel with no discontinuity handling 55 3 43 Submodel with discontinuity handling o ooo o o o oo 59 Modification of the submodel specification 59 Modification of the submodel code 0 0 00000 62 Submodel testa doa da aia asa Shake ide ied d 66 35 Square wave submodel essien eena Rewta te vies 66 Chapter 4 Advanced examples iia e dese aae rae a 75 AL UmCOQUCBIODD La id pd dod als pedo 75 Az iBouncine Dall 225 ias GUERRE Ed 75 4 2 1 Creating category and component icons in AMESet 71 4 2 2 Creating the submodel BL50 for the bouncing ball 78 4 2 3 Creating the floor submodel FL80 o o o ooooooooooooo 82 Use of an enumeration integer parameter 005 90 Using AMELexicon to set parameters 0 000000 eee 92 AMESet 4 2 User Manual 4 2 4 Activity index computations sx A iow 96 Activity index in the ball submodel 97 Act
154. nction the definitions of the three one line macros must be removed since these will be written separately by AMESim Code for tfratio will be moved from crank6 crank6_ to crank6_macro0 crank6macro0 Step 18 Move relevant code into the multi line macro We have the declarations as follows external distim C gt gt gt gt gt gt gt gt gt gt gt gt Extra Macro Function tfratio Declarations Here double precision sint cost root C lt lt lt lt lt lt lt lt lt lt lt lt End of Extra Macro tfratio declarations integer loop and executable statements as follows C gt gt gt gt gt gt gt gt gt gt gt gt Macro Function tfratio Executable Statements C Set common quantities sin theta cos theta Sqrt L L c 1 c 1 sint sint C Set transformer ratio tfratio c 1 sint 1 0d0 c 1 c 1 sint sint C lt lt lt lt lt lt lt lt lt lt lt lt End of Macro tfratio Executable Statements Step 19 Remove unnecessary code from crank6 crank6_ The declaration section now contains nothing C gt gt gt gt gt gt gt gt gt gt gt gt Extra Calculation Function Declarations Here C lt lt lt lt lt lt lt lt lt lt lt lt End of Extra Calculation declarations The executable statement contains only the assign of the dtheta C gt gt gt gt gt gt gt gt gt gt gt gt Calculation Function Executable Statements C Set derivative of rotary speed dtheta omega
155. ndard package provides the two following categories e Mechanical aie e Control signal and observer in In addition you probably have one or more optional AMESim libraries This allows you to perform dynamic simulations of a variety of engineering systems However you can add your own categories You can also remove a category completely from your local configuration when it is no longer needed Add edit and remove a component icon in component category This involves creating icons using the built in con designer and then defining type and location for each of the ports in the icon The setting of port details 1s fully graphical Chapter 1 Introduction 1 2 3 1 2 4 1 3 In addition to adding new icons in a component category you can also modify the details of an existing component icon and its associated submodel You can also delete an icon or submodel from a category when it is no longer needed Create a submodel specification For each submodel there must be a specification file AMESim relies on the specification of a submodel to determine the details of the ports for exchanging information between the submodel and the connected submodels AMESet provides you a graphical environment to set details of external variables and internal variables details of parameters for each of the types real integer and text and also the requirement of discontinuities handling and time input Once you have specified your needs AM
156. ng Started These functions are actually also declared in the C code but the decla ration are in the header file ameutils h Strangely in C they are named disloc distim and disimp There is a good reason for this By add ing the underscore the same utility name can be called as name from F77 code and name from C code The array ic dimensioned at 1 has appeared on the arguments list This is the integer store and in the present submodel it will be used to record the current state of the prime mover 1 e whether the speed 1s a constant Zero before the start up time or 1s rising with time The integer variable loop is introduced to deal with cases where some external or internal variable is an array and is used as a do or for loop parameter Modification of the submodel code The modifications you must make to the code are as follows In F77 subroutine pm51 n omega rp ic flag t integer n ic 1 double precision rp 3 omega double precision t tau integer flag logical logi logical disimp external disloc disimp external distim C gt gt gt gt gt gt gt gt gt gt gt gt Extra Calculation Function Declarations Here lt lt lt lt lt lt lt lt lt lt lt lt End of Extra Calculation declarations omegaf rp 1 tstart rp 2 tau rp 3 Set all submodel outputs below C omega 27 62 gt gt gt gt gt gt gt gt gt gt gt gt Calculation Function Executable Statements
157. nly to Parameters or to Both C Variables Parameters v Bath Title filter This enables you to specify key words and complete sub strings to search for in Parameters Variables You can make the specification more precise using the Case Sensitive and Exact Match check buttons If Exact Match is selected the string must be a sub string of a title otherwise the component words of the specified string are key words Case Sensitive Exact Match Unit filter This enables you to limit the analysis to Parameters Vari ables having a specified unit Note that you can have very restrictive filters and very general filters and both are useful If you select a single library with all parameters but no Title or Unit filters you will have all the parameters real integer and text in that library You can then scroll through the lists looking for inconsistencies If you are certain there are inconsistencies associated with a particular title put a very restrictive Title filter to generate a short list It is then easy the make the titles consistent If you want to make your titles consistent with ones in an AMESim library use the method described in Using AMELexicon to set parameters page 92 to Copy Paste the AMESim title onto your submodel Click on Generate The analysis is performed the results are displayed under the Titles tab see Figure 5 10 161 Chapter 5 Reference Guide for AMESet The Titles Tab for AMELe
158. nough information to introduce 050 using AMESet Associate it with the existing icon shown in Figure 3 26 Do not forget to declare the submodel as requiring time and that there is 1 real store At the moment it does not need access to the discontinuity variable flag and so is declared as not having discontinuities 69 Chapter 3 Getting Started Figure 3 32 Variables parameters stores and submodel requirements Er Ports 1 i Port 1 external variables 1 signal i External variable 1 T Internal variables B t guum I j CANTE TER Real parameter o H Real parameter 2 j L Real parameter 3 z Integer parameters pu Text parameters Integer stores i Fieal stores r3 c c Submodel requirement Submodel requires time Submodel requires discontinuities flag Convert unit ta Si Call to the calculation Function f Always C Never C when printing Test the submodel with the systems shown in Figure 3 30 Figure 3 33 Test systesm for SQ50 DJ Mae e For the first system there are no state variables AMESim will limit the step size to the communication interval unless this is larger than the declared maximum step size SQ50 can do nothing other than return the correct value If you reduce the communication interval to value of say one tenth of the period of the square wave the square wave will be represented very well in the plot e For the second system there are severe problems
159. nt sensor icon is shown 1 Figure 2 3 A typical simple system L5TPOD4 2 Inertia of lever and restriction an movement MASOO5 1 LELOO1 1 2 5 AMESet 4 2 User Manual A very simple mechanical system appears in Figure 2 3 with submodel names added to the figure The code of each component submodel has to calculate various quantities associated with the component The mass submodel MASO002 for example calculates the velocity in m s the displacement in m and the acceleration in m s s at each port In order to do this it requires information about the forces applied at the two ports Each of these quantities is associated with a particular port and is called an external variable External variables are normally available for plotting Inputs and outputs The value of the forces applied to this mass are supplied to MAS002 by the zero force submodel F000 and the clearance submodel LSTP00A This gives rise to the concept of dividing submodel external variables into the categories inputs and outputs Figure 2 4 The inputs and outputs of MAS002 t t ft 4 m s m masts M The external variables calculated by a submodel are its outputs and for MAS002 they are e velocity port 1 e displacement port I e acceleration port 1 velocity port 2 displacement port 2 acceleration port 2 whereas the inputs are e force port l force port 2 Remember that external variables are either inputs or outputs and
160. nterest When compiling the following set of options is useful f77 c g C u e g option prepares the code for use within a debugger e C enables array bound checking e u flags undeclared variables as errors Check statements At this point if you were to continue developing the submodel you would check the value of some variables and warn the user or even stop the simulation run if the user had set completely unsatisfactory values For the time being it is suggested that you look at the code in the 4ME submodels or AME submodels area to see how check statements are inserted rather than actually do the operations yourself You can look at the source code of any submodel called NAME for instance in the AMESim system area You will find that this code contains a description as well as check statements that are very carefully filled The easiest way is to load the appropriate file into your preferred editor Using Unix S AME tutorial submodels N AME f or AME tutorial submodels NAME c or AME submodels NAME c Using Windows AME tutorial submodels NAME f or AME tutorial submodels NAME c or AME submodels NAME c You have read only access to these files and you can print them if you want The check statements test the value of some variables such as real parameters explicit state initial values fixed variables etc If it is an unacceptable value the program may be stopped Note how the statements are placed i
161. o change the compiler and you have created your own submodels you must recompile all your submodels and libraries with new using the batch command files AMEcc Debug bat and AMEcc_Release bat Icons menu Icons Submodel Code To Add category Remove category Add component Remove component Icon designer Change submodel icon Add category If you do not want to use a category icon in the supplied AMESim libraries you must create your own component icon This must be stored in your own category icon Category icon are the ones you see at the left side of the AMESet window The steps involved in creating a new category icon are the following 1 Select Icons f Add category A browser appears AMESet 4 2 User Manual 2 Select a directory for your category Figure 5 69 Browsing for a Folder for an AMESim category Browse for Folder Fl Select a directory for the new category E 3H Floppy 4 H System L HE Data D H E ne Home Prod on Fatsnake H peg Appli on Fatsnake P m Egi Public on Fatsnake 2 59 wes Bi 3 Click on OK If the selected directory is not in the AMESet path list the following dialog box is produced Figure 5 70 Adjusting the Path List FA Not In Path List You can then update your path list and you will be asked for the category name and description As soon as the description is validated the Icon Designer ap pears You can now cre
162. o expand the second rule e Explicit states fixed variables implicit states and constraint variables as external variables are extremely useful Never have an useful variable like this as an internal variable and make a copy to an external variable as a basic variable output This is a complete waste of a useful variable e Use duplicate variables when the same variable occurs on more than one port e If you have an variable as an input to a Inpui aulpul status input port and it is not used in the calculation variable can be plotted yeu remove it or make it an input unused input output input with default input unused In difficult cases where algebraic loops are generated consider using mac ro variables Consider also a different subdivision of a subsystem into submodels with smaller units 129 Chapter 4 Advanced examples 130 AMESet 4 2 User Manual Chapter 5 Reference Guide for AMESet 5 1 Introduction This chapter is designed to be used for reference from the main index It is organized as follows e a description of AMESim nodes e features available from the menu bar e features available from the tool bar e facilities available in the main window including setting the characteristics of ports parameters and variables e debugging submodels created in AMESet e a summary of assignments of variables AMESim Nodes It is important to be aware of the AMESim nodes to be efficient in
163. ocity and we Te will do the same with BL51 Note that there is now no e concept of an external force and we can remove this Y force from the port of BL51 This means that external variables of BL31 look as shown on the right and that it would still connect to the floor submodel FL50 This is very bad because the purpose in life of FL50 1s totally unrelated to that of BL51 e 99 Chapter 4 Advanced examples 100 BL51 and make it an internal variable BL5 will then have external variables as shown on the right and will now be incompatible with FL50 To get over this we will remove the displacement external variable from AA We will later build a special FL5 which is compatible with BL51 ms Step 1 Ensure BL50 is loaded To save time you are going to base the new submodel on the old Step 2 Use File Save as and save the submodel as BL51 Remember there is now no external force Hence we also have 2 variables on the single port which are the velocity and displacement Step 3 We have to delete the last external variable There are two simple ways of doing this Figure 4 52 Deleting an external variable External variable 2 P ZEE sternal variable 3 E mal variables il parameters Insert new ger parameters X Cut del requirements l ae i3 Copy Ibriadel requires time Kp Paste bmodel requires discontin a P Move u insert unit ka 5 t P 4 Move down ta the caloan Finechne 1 Right cl
164. odel 2 C gt gt gt gt gt gt gt gt gt gt gt gt Extra Initialization Function Declarations Here C lt lt lt lt lt lt lt lt lt lt lt lt End of Extra Initialization declarations Here you are invited to make extra variable declarations you which to use in the initialization subroutine or function Suc If necessary check values of the following C rp 1 1 C X C gt gt gt gt gt gt gt gt gt gt gt gt Initialization Function Check Statements C lt lt lt lt lt lt lt lt lt lt lt lt End of Initialization Check Statements Here you have the option to make checks on variable and parameters This sec tion is preceded by comments that suggest the things that you might like to check In this case it 1s the starting value of the state variable the linear dis placement of the rack and the value of the real parameter the radius of the pin AMESet 4 2 User Manual ion 4 C gt gt gt gt gt gt gt gt gt gt gt gt Initialization Function Executable Statements C lt lt lt lt lt lt lt lt lt lt lt lt End of Initialization Executable Statements Here you insert statements that assign variables This will become clearer in later examples 5 C gt gt gt gt gt gt gt gt gt gt gt gt Extra Calculation Function Declarations Here C lt lt lt lt lt lt lt lt lt lt lt lt End of Extra Calculation declarations Here you can declare extra variables and functions for the cal
165. odel ADTO is an example of a submodel with an internal variable It has three ports each with one output e torque at port l rev min El e Nm Mr L CM ee ey min a L E e signal output e angular velocity at port 3 and two inputs e angular velocity at port I torque at port 3 One other variable is also calculated in ADTO e angular displacement This variable is used with a gain and an offset to compute the signal output but it is also useful in its own right Variables like this are of sufficient significance to justify making them internal variables In consequence the angular displacement can be plotted if ADTO is included in a simulation A much more spectacular example of a submodel with internal variables is RSTAT This has no ports and hence no external variables a ya stats It monitors various statistics concerning the integration and stores them using 14 internal variables 2 7 AMESet 4 2 User Manual There is no concept of input output with an internal variable As you will see in the next section variables can be classified into several types Sometimes there is a variable which is an explicit state variable or an implicit variable either implicit state or constraint but it is inappropriate to make it an external variable These three types of variable are not computed by the submodel but rather by the integrator In order to communicate values bet
166. on Use Documentation gt Edit HTML documentation to modify the Sketches and Equations section of your submodel documentation If no HTML editor is specified in the AMESet preferences see section AMESet preferences page 146 you will be asked to select one View HTML documentation Use Documentation View HTML documentation to view the documentation generated for the active submodel In contrast if you use Help OnLine you get documentation on all submodels AMESet 4 2 User Manual Figure 5 8 Viewing HTML Submodel Documentation Qi Help PH50 Sel i le Go Display Bookmarks Contents Indes Search m Qa MECustom E Demo Applications E Demo Libraries PM50 prime mover with startup characteristics I E eL ibraries 2 Manuals Description Technical bulletins PMOOO i a submodel of constant speed prime mover The speed is E Utilities completely independent of the torque on the shaft 5 4 8 Tools menu The function of the second and third items is obvious Tools Documentation Wine AMELesicon Ctrl L Start AMES m Start AME Custom License viewer AMELexicon Use this facility to help you make submodels with consistent titles and units for Parameters and Variables When you use Tools gt AMELexicon the starting point is the AMELexicon dialog box 159 Chapter 5 Reference Guide for AMESet Figure 5 9 The AMELexicon dialog box under the Build tab AL AMELexi
167. or ic 0 1 in C Submodel test Retest the submodel with the same system as before Figure 3 25 Remove the old submodel PM30 by selecting the new prime mover PM51 in Submodel mode After this collect statistics for the run see Figure 3 26 with the modified submodel You should find that the run e 1s faster has fewer function evaluations and e uses a bigger maximum step size The cost is a slightly more complex submodel which must be coded very precisely You can examine the files PM51 f and PM5I c files in the 4ME tutorial submodels or AME tutorial submodels areas the same as with RACK50 3 5 Square wave submodel This 1s the last exercise which deals specifically with discontinuities Clearly a square wave is a discontinuous function Here is some simple code for the square wave 66 AMESet 4 2 User Manual In F77 cycles teu if cycles 2 2 eq cycles then C At minimum value output minv else C At maximum value output maxv endif cycles int t c 0 if cycles 2 2 cycles At minimum value output s minv At maximum value output maxv You are going to create your own square wave submodel using the code above and the icon shown ro This icon can be found in the Signal Control and Observers category Je The following points give indications for constructing this submodel which you will call O50 a 67 Chapter 3 Getting Sta
168. ot Figure 5 7 The Code Type dialog box Code Type E E Source type Object type i Code Release FF code i Debug Advanced Cancel Ze Generate Use Code gt Generate when you want to generate source code c or f for the active submodel The specification must be complete The facility is also available by clicking on the button in the tool bar Edit Use Code gt Edit when you want edit the code of the current submodel The facility is also available by clicking on the button in the tool bar Compile o Use Code gt Compile when you want to compile the code of the current submodel The facility is also available by clicking on the button in the tool bar 157 Chapter 5 Reference Guide for AMESet 5 4 7 158 Documentation menu Documentation Tools Windows Create HTML skeleton Edit HTML documentation View HTML documentation Create HTML skeleton Use Documentation gt Create HTML documentation to create HTML documentation for the active submodel Note The name of the file is inherited from the submodel with an Atml extension e This Atml file is put in the doc directory of the AMESim node in which the submodel is stored e The tml file is constructed from the specification spe and source code c and f of the submodel Fill in the full description part of the source code as this forms a major part of the documentation Edit HTML documentati
169. ove 153 Chapter 5 Reference Guide for AMESet Figure 5 3 The Icon Selection dialog box X Icon Selection OF Cancel Icon designer The Icon designer facility can be started as a general facility if you select Icons gt Icon designer It can also be started when creating a new category icon or when creating an icon for a submodel With the AMESet con Designer you can create and save one or more icons and specify their ports Please refer to the AMESim manual section 6 5 2 Creating a supercomponent icon step 1 to step 6 to learn how to achieve this Change submodel icon Use Icons gt Change submodel icon if you want to replace the existing icon to which the current 1 active submodels is associated You can do the same thing by clicking on the Change icon button In either case a Icon selection dialog box is created Change icon zerospeedsource Figure 5 4 The Icon selection dialog box A Icon Selection Name ed echanical jo zeroforcesource i zerpspeedsource 2 mass pork is mass fiction port 154 9 4 5 AMESet 4 2 User Manual Expand the tree structure and select the new icon Note that you will be presented with subset of icons They are the ones that are compatible with the active submodel It is possible that no icons are suitable In this case you will have to create one or adjust the submodel ports so that it becomes compatible with an existing one Naturally you
170. position rack Derivative name Dimension Min value Default value Max value There is 1 real parameters radius of the pinion Unit Min 100000 Default 10 Max 100000 e The submodel does not generate discontinuities e The submodel does not require time e The submodel does require SI unit conversion Step 2 Create the new submodel For this simple submodel the planning is complete and you can use AMESet to create a specification of the submodel and generate a code skeleton It is good idea to create a special folder or directory called tutorial and do all the exercises in this directory Note that for the rest of the tutorial exercises you should save all your submodels in the same area in which you are now working tutorial directory The process of generating code for new submodels is largely a matter of filling forms Here you 37 Chapter 3 Getting Started are going to use the settings of the already existing submodel RACK00 and alter them to get our own submodel you will call RACK50 1 If necessary reload RACKOO as you did in Step 1 2 In the brief description field type in the text shown below The description field contains text which will be displayed when submodels are selected in AMESim Figure 3 8 The brief description for the rack and pinion submodel Brief description rack and pinion linear velocity input at part 1 with angular position 3 Below is a table in which you w
171. r See also 5 3 Using the category icons page 133 Figure 5 5 A new submodel UNNAMED No icon specified Change icon Brief description I Ports Internal variables Real parameterz Integer parameters Text parameters Integer stores Real stores roo oO Ff oo 135 Chapter 5 Reference Guide for AMESet 136 Open zu Use File P Open to initiate the process of opening an existing submodel z A file browser is displayed and allows you to search for the spe file of an existing submodel The shortcut is Ctrl O The facility is also available by clicking on the icon in the tool bar You are searching for spe files and hence you look in the submodels subdirectory of AMESim nodes Figure 5 6 Browsing for an existing submodel Open Fl Look in C3 submodels E i a PISO spe Files of type Submodel specification files spe Cancel AMESet tries to find the corresponding submodels index from which it can deduce the icon to display Note You can also specify an existing submodel by opening the appropriate category and selecting the icon with which it is associated See 5 3 Using the category icons page 133 You can only open spe files of generic submodels Use AMESim to open generic supercomponents and AMECustom to open customized objects Save Use File Save if you want AMESet to save your complete submodel including the spe file and source fil
172. re Enumeration dialog box 3 Configure Enumeration 2 ES Enumeration list for spline type Related parameters in LI DAT submodel Real parameters Integer parameters al linear E cubic data out of range mode show discontinuity handing show boundary conditions hide data out of range mode hide Hide all Show all Note the three tabs Real Parameters Integer parameters Text parameters Note also the Hide all and Show all buttons In Status dividual hide show values are set using a menu under Status 2 The Default value field by default is set tothe 5 c value extrapolation E first enumeration string It can be changed using m dE the menu available n the Value column Ee e 4 cuclic Note that there are some restriction on enumeration integer parameters hiding parameters Anenumeration integer parameter cannot hide itself e Ifan enumeration parameter can be hidden by another enumeration parameter it cannot hide any parameters The Options button will be insensitive 183 Chapter 5 Reference Guide for AMESet Setting the characteristics of a text parameter There are two ways to select an text parameter 1 Inthe left part of the main menu expand the tree structure in the Type column until you see the text parameter you want 2 Click on it Or 3 Inthe right part of the main window click on the Text parameter tab 4 Adjust the text parameter number by usin
173. ression Tokens Click on the column Value and type in the token s that will be al lowed in the expression of the parameter If more than one token are declared these must be separated by comas or blank spaces Debugging AMESim submodels No matter how carefully you construct submodels you will eventually find yourself in the situation of having a submodel that does not work Finding out why it does not work can be a time consuming and difficult task The main techniques in debugging the submodel are e examining the submodel source code inserting print statements in the submodel code e running the complete simulation in a source code debugger Much can be achieved with the first two techniques provided a systematic approach is used However if you have access to a source code debugger it is well worth learning how to use it It is not appropriate to give a tutorial on any particular debugger in this manual but it is necessary to point out a few special aspects of running an AMESim executable in a debugger The easiest way is to follow the procedure below 1 Compile your submodel in debug mode as opposed to release mode in order to get a special object file for your submodel e Select the AMESet Code gt Code type menu item the dialog box shown below will appear 185 Chapter 5 Reference Guide for AMESet Figure 5 29 Selecting the debug option Code Type Fx Source type Object type ie C code Rele
174. riable 7X Delete From there you can perform the actions on any D E port variable or parameter Move up 4 Move down The possible actions are now described Delete Select this menu item in order to remove the selected port variable or parameter You are asked to confirm If you click on Yes the deleted object is put in the Trash Can Figure 5 22 Confirming a delete Es Please Confirm x ES Do vau really wank to send this port to the trash can Insert new Select this menu item in order to insert a new port variable or parameter 170 Ports AMESet 4 2 User Manual Cut Select this item in order to remove the selected variable or parameter It is put into a buffer or clipboard and you can then use Paste to put it somewhere else This does not apply to ports Copy Select this item in order to make a copy of the characteristics of the selected variable or parameter in the clipboard You can then use Paste to put it somewhere else This does not apply to ports Paste Select this menu item in order to assign to a variable or a parameter the same characteristics as in the clip board This does not apply to ports Move up down Use these menu items if you want to change the place of the selected port variable or parameter Note that for external variables AMESet prevents you from breaking the following rules Outputs must always be placed before Inputs Inputs must always be placed before Inputs
175. rivative Other functions have discontinuities in their second or higher derivative These are not artificially constructed examples but rather examples that do occur in modeling work Figure 2 13 Saturation i Here are some other examples of discontinuities e any form of backlash e transition from linear to turbulent characteristics in an orifice e frictional stick slip e any form of dead band e avalve such as a check valve that has characteristics when open which are completely different to when closed e any form of hysteresis any sort of duty cycle involving steps or ramps e submodels which employ linear interpolation for empirical data Why is it necessary to stress the occurrence of discontinuities in simulation submodels The problem lies in the integration algorithms used for solving the o d e and d a e equations that arise in simulation They are based on integration using methods which assume that the state variables and some of their derivatives are continuous If this assumption 1s not true special precautions have to be taken at the discontinuity points This can be illustrated by a simple graph shown in Figure 2 14 27 Chapter 2 AMESim Submodels Figure 2 14 A function with a discontinuous derivative t dis The variable has two distinct characteristics resulting in two very different curves C1 and C2 The variable is continuous but the derivative is discontinuous at the point P The integration
176. rminating the program Nn AmeExit 1 Common SI Conversions rp 0 x 1 00000000000000e 003 radius rp o0 AMESet 4 2 User Manual 43 Chapter 3 Getting Started gt gt gt gt gt gt gt gt gt gt gt gt Initialization Function Executable Statements lt lt lt lt lt lt lt lt lt lt lt lt End of Initialization Executable Statements There are 2 ports Port number 1 has 2 variables Variable number 1 f1 function expression is t2 radius force at port 1 N Variable number 2 v1 variable scalar input linear velocity at port 1 m s Port number 2 has 2 variables Variable number 1 w2 function expression is vl radi us rotary velocity at port 2 rev min Variable number 2 t2 variable scalar input torque at port 2 Nm xy There are 2 internal variables Variable number 1 x explicit state scalar derivative dx displacement of the rack mm gt m Variable number 2 theta variable scalar angular position degree gt rad ifdef NO PROTO void rack50_ n vl t2 x dx theta rp int n double v1 double t2 double x double dx double theta double rp 1 else void rack50 int n double v1 double t2 double x double dx double theta double rp 1 Hendif theta int logi gt gt gt gt gt gt gt gt gt gt gt gt Extra Calculation Function Declarations Here lt lt lt lt lt lt l
177. rtain situations can create difficulties Thus very small hydraulic vol umes and very small masses subject to large forces can cause problems The State count facility can be useful in identifying the cause of a slow simulation An eigenval ue analysis can also be useful The author remembers spending many hours trying to understand why a simulation failed Eventually he discovered that he had mistyped a parameter A hydraulic motor size had been entered making the unit about as big as an ocean liner When this pa rameter was corrected the simulation ran fine It follows that you must spend some time investigating why a simulation runs slowly or fails completely However it is possible that you have discovered a bug in an AMESim submodel or utility If this is the case we would like to know about it By reporting problems you can help us make the product better On the next page is a form When you wish to report a bug please photocopy this form and fill the copy You telephone us having the filled form in front of you means you have the information we need Similarly include the information in an email To report the bug you have three options reproduce the same information as an email telephone the details e fax the form Use the fax number telephone number or email address of your local distributor HOTLINE REPORT Creation date Created by Company Contact Keywords at least one Problem type Bug Summary Descrip
178. rted The submodel SQ50 has a single external variable which we have referred to as output Figure 3 30 The external variable for SQ50 port 1 zi external variable 1 External variable settings Variable generalities Setting Type of variable basic variable Input aeutput status output Variable can be plotted True MM I Variable details Setting Title output from square wave Unit null Variable name output Dimension The frequency in Hz is a real parameter which can be denoted by f Figure 3 31 Frequency in Hz Er Forts 1 Port 1 external variables 1 External variable 1 pu Internal variables 0 BEHealpaametes 3 z Real parameter 1 pa Real parameter 2 o i Real parameter 3 z Integer parameters Text parameters Integer stores i Real stores c c3 c3 e The variables minv and maxv are also real parameters representing the minimum and maximum values of the square wave This gives three real parameters frequency of square wave Hz minimum value null maximum value null 68 AMESet 4 2 User Manual e The variable cycles is local to the calculation routine of the submodel and must be declared in the declaration section of the calculation routine as follows C gt gt gt gt gt gt gt gt gt gt gt gt ExXtra Calculation Function Declarations Here integer cycles C lt lt lt lt lt lt lt lt lt lt lt lt End of Extra Calc
179. ry Gothic E Comic Sans MS Courier Effects Strikeout Underline Script Latin Font style Size Normal la Normal E cl Italic T Bold B D l A lt l a Sample AaBbYwvZz N c Clicking on Code format produces the Code Format dialog box as shown in Figure 5 17 Use this to employ colors and styles for the selected item and make the structure of the code clearer Figure 5 17 The Code Format dialog box Ei Code Format Ei key words strings invalid code F77 Italic Bold Color m Sample 148 AMESet 4 2 User Manual Compilers Using Windows Figure 5 18 The Compilers tab for AMESet Preferences n AMESet Preferences Using Unix Figure 5 19 The Compilers tab for AMESet Preferences AME Set Preferences vi AMESet needs a compiler to produce object files for submodels Under this tab you can select C or F77 and Release or Debug See also section 5 4 6 Code menu 149 Chapter 5 Reference Guide for AMESet 9 4 4 150 Using Windows AMESet provides GCC as a free compiler You may also use the Visual C compiler Changing the default compiler Do the following 1 Goto Options AMESet Preferences The AMESet Preferences dialog box appears 2 Select the tab Compiler 3 Click on the radio button for the compiler of your choice 4 Click on the OK button What about the user submodels If you want t
180. s dialog box Figure 5 14 The General tab for AMESet Preferences MARTES Preferences El ES General Editors Compilers vw Preview in file browsers Application font Automatic window close on successful compilation Background f Color mi C Image NEAR 18 E Number of files in Last Opened Files list 4 Restore standard Apply Cancel Note the whatever changes have been made you can always click on Restore standard Options are grouped under three tabs General The Preview in file browsers check box applies to the Background area when the Image button is selected The Application font button allows you to select the font to be used by AMESet You can change the background color of AMESet or use an image for it with the Color and Image radio buttons The function of the other facilities is obvious from their titles 146 Editors Restore standard Apply AMESet 4 2 User Manual Figure 5 15 The Editor tab for AMESet Preferences Bi ameset Preferences El Ed General Editors Compiles W Use AMESet fallback editor Tabs Text fant C Keep tabs Insert spaces Number of spaces 3 EI Code format External code editor MSDEV exe n HTML amp equation editor El If you are using AMESet for the first time AMESet will use a built in editor known as the fallback editor It was originally intended that this editor would be rarely used
181. s dialog box will achieve little Reducing the Maximum time step to say one tenth of the period 0 01 will be more successful and you should get results similar to what is shown in Figure 3 33 However if the sim ulation is run for say 1000 seconds inaccuracies become apparent Try this with the Communication interval increased to 1 second to avoid over large re sult files Repeat these experiments with the standard square wave submodel SOWO0 You can do this by removing SQ50 and replace it by SOW0 Make sure you reset the 71 Chapter 3 Getting Started 72 Maximum time step back to its default 1 0e30 you will get the following results Figure 3 36 Results using SQ50 1 INTU 1 output from integrator null 0 010 0 000 0 010 0 020 0 030 0 040 0 050 0 060 E 4 b B 10 Time 2 How does this submodel achieve so much more accuracy The answer is simply that it employs the principles of locating discontinuities and ensuring the integrator always integrates continuous functions Here are some simple modifications you can employ for SQ50 to make it perform as well as SOWO 1 Start AMESet and select Q50 2 Alter the submodel specification as follows e Set the number of real stores as 2 e Set the number of integer stores as 1 Declare the submodel as having discontinuities 3 Regenerate the code 4 Change the calculation routine as shown below 5 Runa simulation with AMESim using SQ50 ins
182. s for categories The ico files define the icons for the components in the category the icon description and the position and type of their ports Files and folders in the submodels folder AMESet creates e spe files which specifies the characteristics of the submodel These files are read by AMESim and specify how the call is to be made to the submodel 132 9 3 AMESet 4 2 User Manual e cor f files which are the source code of the submodels e o or obj files which are the object code of the submodels created when the source is compiled On some platforms these are stored in a special sub directory of submodels and in others directly in submodels Submodel Libraries It is not a good idea to create submodels and supercomponents scattered around the disk system in a random fashion Concentrate them into a small number of AMESim nodes grouping them together so that all objects in a node have a unifying theme The node can then be described as a submodel library All AMESim submodel libraries are organized in this way Figure 5 1 is actually the AMESim cooling system library Using the category icons If you select a category icon you get a dialog box in exactly the same way as with AMESim AMERun and AMECustom Figure 5 2 The icons in the Mechanical category A Mechanical Tx NILLLL m EVE dh PRA GSES GGG dol ed d h pL II n nnn saaa a ra 0 E LH 133 Chapter 5 Reference Guide
183. s for supercomponents using AMESim The process is exactly the same in AMESet but the method of starting the process is different Creating category and component icons in AMESet In AMESet the processes are started from the Icons menu in the menu bar The steps to follow are Step 1 Decide if you need to create a new category icon If you already have a suitable category go to step 3 Icons Submodel Code Add category Remove category Step 2 Create a new category icon _ Add component Remove component 1 Icons Add category Icon designer 2 Create the new category icon If necessary refer to section 11 4 7 Icons menu of the AMESim manual If you have no idea what the icon should look like here is a suggestion Tutorial Esa mp les Step 3 Create an icon for the ball with a single linear shaft port 1 Icons Add component icon 2 Create the ball icon If necessary refer to section 11 4 7 Icons menu of the AMESim manual Do not forget to add the style of the single linear shaft port and to specify its position Here are two suggestions for different levels of ar tistic competence 77 Chapter 4 Advanced examples 4 2 2 78 Figure 4 37 Examples of ball icons Step 4 Create an icon for the floor with a single shaft port 1 Icons Add component deje irte o mal Add category Remove category Add component Remove component Icon designer Ch
184. s of a text parameter 184 5 7 Debugging AMESim submodels 0 0 0 0 cece eee 185 5 8 Summary of variable assignments o oo o ooooooooooooooo 186 5 9 Useful shortcuts for AMESet 2 0 0 0 cece ene 190 Appendix A Creating your own Fluid Properties eee 191 ntrOdU UE uso cox duet wu aati A E cr re a Bc p cts 19 New Fluid Properties mathematical model 191 Creating the new FP50 submodel ooooo o 192 AMESet 4 2 User Manual Chapter 1 Introduction 1 1 1 2 1 2 1 1 2 2 What is AMESet If you are an advanced user you can extend AMESim by adding both new icons and submodels using the separate utility AMESet It provides a comprehensive graphical user interface for doing this AMESet is the abbreviation of Advanced Modeling Environment Submodel editing tool AMESet allows you to integrate new icons and submodels into the AMESim package so that they can be used just like standard AMESim icons and submodels Producing new submodels involves writing your own code that must be in the correct format to allow AMESim to call it AMESet creates a code skeleton in this format to which you add your own statements to implement your submodel Using these facilities an experienced AMESim user can create his own submodels according to the needs of a particular application AMESet functionality Add and remove a component category The sta
185. se refer to the AMESim manual section 6 5 2 Creating a supercomponent icon step 1 to step 6 to learn how to create an icon and add ports to it Finally click on the Save icon to 152 AMESet 4 2 User Manual AMESim files button of the con Designer dialog box Load a bitmap from a file A file browser allows you to load a bitmap from a file Select an existing icon from another category Select the icon you want within a list of existing icons When you have designed the icon and set its fields properly click on the OK button Remove component To be able to remove a component icon e you must have write permission for the ico file to do the removal there must be no submodel associated with the icon Step 1 Select Icons P Remove component The Remove Icon dialog box appears Figure 5 2 Removing a Component Icons Fl Remove Icon El ES Select the component icon vou want to remove Icon Select Parent category Mechanical Step 2 You can select the icon in two ways Hydraulic Valves 1 Ifyou know the icon name and the category enter the icon name and select the Parent category Maii Hydraulic ERRARE eee re SE Thermal Hydraulic Resistance Thermal Hydraulic Valves Mechanical Signal Control and Observers Hydraulic Component Design Hydraulic Resistance Pneumatic Pneumatic Valves Or 2 Click on the Se ect button and click on the component icon you want to rem
186. ssion radius Submodel requires time Submodel requires discontinuities flag I Convert unit ta Si Call ta the calculation funcion B Always C Never C When printing 34 AMESet 4 2 User Manual 2 Examine the details of the existing submodel First concentrate on the tree structure on the left shown below Figure 3 5 Ports variables and parameters for RACKOO Er Ports 2 Er Port 1 external variables 2 lshaft pu External variable 1 External variable 2 H Port 2 external variables rshatt E Internal variables E Real parameters z Integer parameters pu Text parameters e Integer stores t Heal stores roo oOo et pi Currently Port 1 external variables and External variable 1 is selected and in the right hand side of the display details of this external variable are displayed Figure 3 6 External variable External variable settings Variable generalities Setting Type of variable one line macro Variable can be plotted True Variable details Setting Title force at port 1 Unit M Variable name Fl Expression bev 3 Examine other details as follows e Select port 1 External variable 2 Expand Port 2 external variables and select in turn each of the two ex ternal variables Expand nternal variables and select the single internal variable Expand Real parameters and select the single real parameter e Note the status of the Submodel requiremen
187. state variable theta or theta using your favorite integration method Instead you must define the derivative of the state variable omega or omega and from this derivative this is the AMESim integrator which calculates the state C language specific features If you ask AMESet to generate your submodel code in C you must be aware of conventions which are specific to this programming language e AMESim generates calls to submodels without consideration as to whether they are written in F77 or C In practice this means that all variables on the argument list will be referenced as pointers If variables that are used in assignment statements are on the argument list they will have a in front of them Thus you have dx vl theta x radius rather than dx vl theta x radius e Some Unix versions of C conform to the ANSI standard and use full function prototypes Others do not You will notice constructions of the type Hifdef NO PROTO some statements Helse some different statements Hendif The first set of statements 1s for versions of C which do not accept full function prototypes and the second for those that do If compilation is performed with a D_NO_PROTO 50 AMESet 4 2 User Manual option the first set of statements will be compiled otherwise the second set will be compiled Compilation flags for Fortran below Unix For F77 users under a Unix environment the following information may be of i
188. submodel an estimate for both the state variable and its derivative Submodels use these values to compute a residual The integrator then tries to make the residual zero e The residual has units which can be unrelated to the units of the implicit state variable The state is defined by a starting value and an implicit expression for the derivative which is associated with the residual in the submodel code An example of such an expression is given below Ox F C 9 x ot ot 5 0 t This expression is used to define the residual in the submodel code B x x PELOS e or Ot To underline the distinction we take a second example Imagine the one dimensional motion of an object of mass M kg under the action of two forces fI N and f2 N so that it moves with velocity v m s If we used an explicit state we could have the following code de ORB doe doe Calculation Function Executable Statements uldot i F2 F1 M fe rn A End of Calculation Executable Statements Here we explicitly define v dot the derivative of v On the other hand we could use an implicit state with the following C code fe Boe eoee eee o gt Calculation Function Executable Statements e On entry vidot is the derivative of vi uldot M etevidoti ixF2 Fl f On exit vidot is the residual of v1 fe C4dededddd lt lt End of Calculation Executable Statements The important point is that the same variabl
189. t lt lt lt lt lt End of Extra Calculation declarations int loop double radius 44 AMESet 4 2 User Manual radius rp I Common gt SI units conversions x x 1 00000000000000e 003 Set all submodel outputs below gx gt gt gt gt gt gt gt gt gt gt gt gt Calculation Function Executable Statements dx vl lt lt lt lt lt lt lt lt lt lt lt lt End of Calculation Executable Statements SI Common units conversions 3 1 00000000000000e 003 dx 1 00000000000000e 003 theta 1 74532925199433e 002 1 Alter the code as follows in the Calculation Function Executable Statements gt gt gt gt gt gt gt gt gt gt gt gt Calculation Function Executable Statements xdx v 1 theta x radius End of Calculation Executable Statements In F77 C gt gt gt gt gt gt gt gt gt gt gt gt Calculation Function Executable Statements dx v1 theta x radius C lt lt lt lt lt lt lt lt lt lt lt lt End of Calculation Executable Statements 45 Chapter 3 Getting Started ls As the automatic SI unit conversion is applied you do not have to take care of the units e v isin m s e theta is in degree e xand radius are in mm These variables are all converted to SI units before the executable statements so that the formula giving theta does not requir
190. t On share the same name accel vdot On entry set to derivative vdot must be reassigned to On exit must be set to the residual the residual vdot mass vdot force if flag eq 0 then The state variable may if x gt xmax then b bce e assigned only if flag 0 0 0 Constraint Explicit assignment of variable residual Duplicate No code There is no access to variable duplicate variables in the calculation function On line macro No code There 1s no access to variable one line macro variables 1n the calculation function Multi line macro No code here but in the multi line macro variable variable function 188 AMESet 4 2 User Manual Type of variable Example of code in calculation Comment function subroutine Fixed variable No code here There is no access to fixed variables in the calculation function Activity variable powImass mass accel v Explicit assignment of associated power variable 189 Chapter 5 Reference Guide for AMESet 5 9 Useful shortcuts for AMESet 190 AMESet 4 2 User Manual Appendix A Creating your own Fluid Properties Introduction Please note that this appendix is intended only for users having access to the Hy draulic library If you have access to the Hydraulic library AMESim permits you to simulate sys tems containing more than one fluid FP04 is a standard fluid properties submodel supplied in the AMESim Hydraulic Library If you have your own i
191. tarted and we will return to these problems when we have the model running and can study the pathological cases in detail Notice that the only force applied to the ball in this equation is the weight of the ball There is no reference to any external force Hence it is not necessary for the floor submodel to return any value for the force between the ball and the floor It is probably more convenient to define the values of the displacement at which the ball hits the floor and the coefficient of restitution within BL51 as real parameters Step 6 Alter the number of real parameters to 2 Set the new real parameters as follows Title displacement at which ball hits floor coefficient of restitution Unit null Min Default 10 Max Step 7 Modify the new brief description to AMESet tutorial bouncing ball 2 Generate the code for the submodel Step 8 Load the code into your favorite editor and insert the Fortran code of the previous page into the calculation function subroutine Alternatively if you are using C you are probably using an integer local variable cond Here is some code in C for this example The extra definition of cond is essential 103 Chapter 4 Advanced examples 104 cond y lt y0 if flag 0 Integration just started or restarted Check position of ball if ey gt y0 Displacement is invalid and must be reset Bounce the ball oS If necessary reset velocity
192. tations in both the ball and the floor submodels This is done by adding an internal variable of type activity variable For this variable we must define a physical type R C D a physical domain hydraulic mechanical electrical and a suffix You do not have to give it a special title because this is constructed from the other fields The units are always J Note that none of the other submodels you have created so far need activity index The rack submodel RACK50 is an ideal transformer There is no dissipation R there is no inertia 7 and no energy is stored C e The prime mover PM50 is a pure source e The square wave submodel SO50 like all the submodels in the Signal Control and Observers does not involve energy exchange For each activity variable AMESet automatically defines a power variable which is declared at the beginning of the calculation function This power variable must be assigned in a special section of the calculation function subroutine known as the Activity Computation Statements The power is then used by AMESet in order to calculate the corresponding activity In the case of a linear mechanical submodel the power is defined as follows P FxV where F is a force applied to the submodel and V its linear velocity AMESet 4 2 User Manual Activity index in the ball submodel Concerning the ball submodel we need one activity variable that will be associated with the inertial power of the ball St
193. te variables and so any changes you might make to state variables do not normally reach the integrator The only exception to this is as follows When flag 0 you are allowed to change the value of explicit states implicit states or constraint variables At no other times are you allowed to change these values Step 5 Tick the check box Submodel requires discontinuities flag Submodel requirements Submodel requires time Submodel requires discontinuities flag Convert unit ta 51 Call to the calculation Function f Always C Never C when printing Provided the submodel is declared as having discontinuities we have access to the flag variable and we can rewrite the calculation section as follows if flag eq 0 then C C Integration has just started or restarted C Check value of y C if y gt y0 then C C Ball has hit the floor C y yo v coefr v 101 Chapter 4 Advanced examples 102 endif endif if disimp y le y0 ic 1 then C C Ball is still falling freely C ydot v vdot 9 81 else if disimp y gt y0 ic 2 then C Ball is in illegal position C ydot 27 VOCE endif There are two problems here First it is not clear how we should set ydot and vdot when y gt y0 However after a little thought it is clear that the second branch is totally unnecessary A little explanation is necessary e At the start of the integration and after any restart flag will be
194. tead of SOWO and check you get proper results as in Figure 3 33 AMESet 4 2 User Manual In F77 if flag eq 0 then C The integration has just started or restarted cycles t c 1 C Determine time of next discontinuity c42 cycles 1 e 1 C Determine which value will be used if eyeles 2 2 eq cycles then C At minimum value 26 1 10 else C At maximum value Lo le 1 endif endif C Set output according current state if ic 1 eq 0 then output minv else output maxv endif C Check for discontinuity call distim c 2 73 Chapter 3 Getting Started TJt Elag 0 The integration has just started or restarted gveles Int FCO TOI Determine time of next discontinuity c 1 cycles 1 c 0 Determine which value will be used Xl eyeles 2 2 Cycles At minimum value Te LOM ux 205 At maximum value ic 0 1 output Check for discontinuity distim amp c 1 AMESet 4 2 User Manual Chapter 4 Advanced examples 4 1 4 2 Introduction In this chapter you are introduced to more discontinuity facilities more on duplicate variables macro and activity variables inaddition you are given advice on how to avoid algebraic loops We assume that most C programmers can understand Fortran 77 but probably the reverse is not true Hence we present the code of most examples in Fortran 77 but
195. the code and view it in an editor For this example you should use C or willlose the executable statements inherited from RL02 The code will be identical to RL02 apart from the function names Notice that the duplicate variable wdup is not available This is because AMESim manages duplicate variables and will not give you an opportunity to mess things up Step 5 Change port 1 variable 1 to a basic variable output Generate the code and modify calculation function subroutines as follow wdot torq1 torq2 J accel wdot wdup w Note that the variable wdup is now known in the calculation function and we have an explicit assignment of it Step 6 Using AMESim create the system shown Make sure you select the original submodel RL02 If the system is called NAME AMESim will generate code called NAME c Load this code into an editor and search for the call to the function ri 2 The code looks complex and there are special calls that deal with discontinuity handling and with linear analysis Below is a simplified version with lines of code irrelevant for this discussion removed AMESet 4 2 User Manual Assign the state variables y calculated by the integra tor to the appropriate variables v This is fhe siate variabile DO Call submodels in the order that ensures the input requirements of each submodel are satisfied 1000 n 107 d This ds fhe sign reversed dupli
196. ther simple or reversed sign The default type is simple basic variable explicit state implicit state constraint duplicate variable fed variable one line macro multi line macro input output input with default input unused sign reversed AMESet 4 2 User Manual Variable details l Title This characteristics is common for all the types of external variables except for the type duplicate variable Click on the column Value and type in a title for the external variable This title will appear in AMESim when you will use the submodel Unit This characteristics is common for all the types of external variables except for the type duplicate variable Click on the column Value and type in the unit of the external variable Alternatively you can click on the button El in the column and you will get a dialog box for selecting the unit Figure 5 25 The Unit Chooser Unit Chooser Fa enthalpy Tow rate and power E fluid absolute viscosity p H fluid bulk modulus see hyd pneu pressure i fluid kinematic viscosity H frequency geometrical angle degree rad F ev geametrical area rad Find 3 Itis a difference This is a boolean field which becomes available only when the external variable has a unit set to either a pressure bar Pa barA or a temperature degC degF Set this field to True when the variable is either a pressure drop or a temperature differenc
197. tion Involved operating system s O All O Unix all O HP O IBM SGI SUN Other Involved software version s O All O AMESim all O AMESim 4 0 O AMESim 4 0 1 AMESim 4 0 2 AMESim 4 0 3 O AMESim 4 1 O AMESim 4 1 1 O AMESim 4 1 2 O AMESim 4 1 3 AMESim 4 2 O AMERun all O AMERun 4 0 O AMERun 4 0 1 O AMERun 4 0 2 O AMERun 4 0 3 O AMERun 4 1 O AMERun 4 1 1 O AMERun 4 1 2 O AMERun 4 1 3 AMERun 4 2 O Improvement 1 PC all AMECustom 4 2 User Manual Other Windows 2000 UO Windows NT Windows XP Linux O Other O AMESet all O AMESet 4 0 O AMESet 4 0 1 O AMESet 4 0 2 O AMESet 4 0 3 O AMESet 4 1 O AMESet 4 1 1 O AMESet 4 1 2 O AMESet 4 1 3 Ol AMESet 4 2 AMECustom all AMECustom 4 0 AMECustom 4 0 1 L AMECustom 4 0 2 AMECustom 4 0 3 O AMECustom 4 1 L AMECustom 4 1 1 O AMECustom 4 1 2 O AMECustom 4 1 3 AMECustom 4 2 Web Site http www amesim com Headquarter amp Development Center IMAGINE S A Roanne Tel 33 4 77 23 60 30 Fax 33 4 77 23 60 3 1 E mail hotline amesim com FRANCE SWITZERLAND SPAIN PORTUGAL BENELUX IMAGINE S A Paris Tel 33 1 39 43 08 12 Fax 33 1 39 43 52 19 E mail hotline amesim com ITALY SWITZERLAND IMAGINE S A Lyon Tel 33 4 37 69 72 30 Fax 33 4 78 54 39 61 E mail hotline amesim com UK IMAGINE v x Tel 44 0 1869 351 994 Fax 44 0 1869 351 302 E
198. to break algebraic loops but a few words of advice e Do not over use macro variable e Start by constructing submodels in a very simple way It is much easier to debug a submodel that does not contain macros Only introduce macro variables if there are good reasons for doing so This usually means a tendency to produce algebraic loops Transformers in particular benefit from macro variable 127 Chapter 4 Advanced examples 4 5 4 6 128 Line submodels Hydraulic pneumatic and any other lines are a little different from other AMESim components There is no special category in AMESim from which they can be selected and their icon is not fixed Its size and shape are determined when the line is drawn To enable submodels of lines to be constructed in AMESet a special L category for lines appears at the top of the other categories Lines This produces a small collection of specific icons You use these just like any other specific icons Note that all line submodels have two ports Avoiding algebraic loops The concept of the algebraic loop was introduced in this chapter Briefly there is an algebraic loop when there is no order in which the submodels can be called such that all the inputs of each submodel are known when the submodel is called AMESim overcomes this problem by introducing implicit variables to break the algebraic loop The result is differential algebraic equations but they are generally easy to so
199. tp double tcelsius double double p gdensity 1 press gpcoeff gp2coeff press p p AMESet 4 2 User Manual return 0 005 j lt lt lt lt lt lt lt lt lt lt lt lt End of Private Code Finally add the following lines in the fp50in executable statements gt gt gt gt gt gt gt gt gt gt gt gt Initialization Function Executable Statements Global variables used in the local atp functions are set here gpcoeff pcoeff gp2coeff p2coeff gdensity density Install the fluid properties fpuserd_ amp fpi rhoatp bmatp muatp sethdind amp fpi lt lt lt lt lt lt lt lt lt lt lt lt End of Initialization Executable Statements Save your modification in a suitable AMESim node and compile the new submod el You are now ready to use your new personal fluid submodel Start AMESim in your working directory and build the system below Figure A 3 Build this system Select the FPROP submodel for the fluid props icon and set the parameter index of hydraulic fluid to 1 Change the parameters of the pressure input to get a ramp from 0 to 200 bar in 10 seconds 195 Appendix A Start a simulation and plot the density the bulk modulus and the viscosity against the pressure Figure A 4 See the results 1 FRPROP 1 fluid density kg m3 ne s eB 7 ME a ane ake ood sare one pecu cud FPR P 1 input pressure bar ea 0
200. ts at the bottom left 35 Chapter 3 Getting Started Figure 3 7 Submodel requirements Submodel requirements Submodel requires time Submodel requires discontinuities flag Convert unit to 51 Call to the calculation Function f Always C Never C when printing 4 Just in case you have made any accidental changes do File Close Step 1 The next stage is to plan carefully what you are going to do 1 You will use the standard rack and pinion icon which has 2 ports 2 You will base the new submodel on RACK00 which has four external variables and one internal variable 3 RACK50 will have the same external variables but two internal variables The additional one being the angular position of the pinion You are going to edit the submodel RACK0O0 and alter it slightly in order to introduce this extra in ternal variable 4 You will then save it as RACK50 According to this plan RACK50 will have the specifications listed below They are the same as RACK00 except the one in bold There are 2 ports Field Port 1 variable Port 1 variable Port2 variable Port2 variable 1 2 1 Type oneline macro basic variable oneline macro basic variable input input Title force at port 1 linear velocity rotary velocity torque at port 2 at port 1 at port 2 36 AMESet 4 2 User Manual e There are 2 internal variables Internal variable 1 Internal variable 2 Title displacement of the angular
201. types AMESet 4 2 User Manual ol TS 2 E Port 1 external variables 3 undef Append new external vari e Port 3 external Internal valables X Delete i Heal parameters Insert new Integer parameters i Test parameters Move up H Integer stores 4 um gt Baal akaran If you find under the Misc column of an item corresponding to a port the key word undefined you must change this to a standard port type The simplest way to do this is to select an icon for the submodel The ports will inherit the port type from the icon You can always edit the port type Do this as follows Right click on the entry in the Misc column and select the type of port you want Remember AMESet will not allow you to save until the port type is defined Declaring external variables E Port 1 exter undefined m Port 2 exter flor oe Fort 3 ester nternal variables Seal parameters nteger parameters Text parameters nteger stores Seal stores 3 0 0 0 O D 0 0 0 plow signal rshaft lzhaft elect thermal magnet rope undetined These variables are associated with the ports of the submodel If there are no ports there can be no external variables Set up the ports before you declare external variables See Ports page 171 To declare external variables on a port 1 Select the port 2 Editthe Numbers field directly or using the spin box arrows Er Forts E Port 1
202. ulation declarations Or gt gt gt gt gt gt gt gt gt gt gt gt Extra Calculation Function Declarations Here int cycles lt lt lt lt lt lt lt lt lt lt lt lt End of Extra Calculation declarations It is used to count the number of semi periods that have been covered e The variable c 1 or c 0 is a real store element and will be set to half of the period It will be set in the initialization code section for executable statements as follows C gt gt gt gt gt gt gt gt gt gt gt gt Initialization Function Executable Statements c 1 0 5d0 C lt lt lt lt lt lt lt lt lt lt lt lt End of Initialization Executable Statements or gt gt gt gt gt gt gt gt gt gt gt gt Initialization Function Executable Statements c 0 0 5 E lt lt lt lt lt lt lt lt lt lt lt lt End of Initialization Executable Statements Note that the device if cycles 2 2 eq cycles then Or if cycles 2 2 cycles is used to determine whether cycles is even or odd This is quite an old trick but for those who have not seen it before a short explanation is required Suppose cycles 5 It follows that cycles 2 is 2 as the rule is to round towards 0 for integer division cycles 2 2 is 4 and the test is false If on the other hand cycles 6 cycles 2 is 3 cycles 2 2 is 6 and the test is true This gives a very simple test for an integer being even You now have e
203. used to deter mine the equivalent diameter 23 Chapter 2 AMESim Submodels In the orifice submodel OR000 an integer parameter is set to 1 to select the flow rate pressure drop method and 2 to select the diameter method This is called a standard integer parameter There are two integer parameters in OROOO Figure 2 11 Two standard integer parameters in OROOO AMESim Parameter Mode Preview E Submodel OR000 External variables Hed hydraulic orifice transition at specified How number E eevee Gar UU NU ane for pressure drop flow rate pair 2 for orifice uw S Index of ae Fluid a n RNC pressure drop 1 bar The signal source submodel UDAO1 uses a different type of integer parameter This is called an enumeration integer parameter The options are represented by meaningful text strings UDAOI contains 3 enumeration parameters Figure 2 12 Changing an enumeration integer parameter 4 AMESim Parameter Mode Preview ki Submodel UDAUI E External variables signal from ASCII file data Parameters spline type linear data out of range mode extrapolation discontinuity handling E 2511 name of ASCII file Real and integer parameters have titles associated with them They also have minimum default and maximum values For real parameters you can set a value outside the range defined by the minimum and maximum value This is not allowed for integer parameters
204. utputs on other ports On other occasions an input is received on one port and is passed without modification to become an output on one or more other ports In both these situations the copies of the original variable are known as duplicate variables The original is called the primary variable There is a further classification of duplicate variable simple and reversed sign 15 Chapter 2 AMESim Submodels 2 11 2 2 11 3 16 Often the duplicate variable has the same sign as the primary However it can be convenient to have duplicate variables with the opposite sign to the primary This is because of the sign convention used by AMESim If the primary variable was a velocity state variable the same variable but with reversed sign might be required for another port Note that in Figure 2 9 the variable v is a reversed sign duplicate of the state variable v Similarly x is a reversed sign duplicate of x and a is a reversed sign duplicate of a If there is no sign reversal it is a simple duplicate You do not make any assignment of a duplicate variable in your submodel This is done for you outside of the submodel Use duplicate variables as much as possible One line macro The concept of a duplicate variable involves taking the assignment of the variable outside of the submodel As you will later in this section simple duplicates will lead to AMESim not AMESet generating code like v 23 v 56 for a simple duplic
205. value Since the value is fixed you set the value of the fixed variable and AMESim will leave the variable unchanged until the run stops naturally or is stopped by you AMESim derives many advantages from fixed variables and you are encouraged to use them wherever appropriate An example of a submodel with a fixed variable is the constant signal source submodel CONSO which has a single output constant value which is a fixed variable Internal variables may be fixed variables although it 1s difficult to see any advantage from this arrangement Fixed variables should be used where appropriate instead of basic variables because they help avoid algebraic loops 2 13 Activity variables 18 The final category of variable is widely used in submodels where energy transfers take place The activity of an element 7 in a submodel is defined as a temporal integration of the power absolute value t A t JIPOI dt 0 where P is the power in the element The units are J The activity represents a quantity of energy that crosses the studied element This is a different definition from energy because it takes into account the absolute value of power An activity variable is always associated with a power variable It is the user responsibility to assign a value to the power variable in the submodel code The activity is then calculated by AMESim from the power Use this kind of variable when you want the activity of your submodel to be calcul
206. ween the submodel and the integrator these variables must be made internal variables and cannot be local variables even if we are not interested in plotting graphs of them Types of variables Further classification of external and internal variables is necessary There are eight special types of variables which will now be introduced e Explicit state variable e Implicit state variable e Constraint variable Duplicate variable simple or reversed sign e One line macro variable e Multi line macro variable e Fixed variable All of the above if they are external variables are outputs There is one type of variable which can only be an internal variable this is an e Activity variable Any external or internal variable that does not fit into one of these categories AMESim refers to simply as a basic variable giving a total of 9 variable types These can be used as follows Chapter 2 AMESim Submodels 2 8 10 Variable type External variable Internal variable Basic Variables The basic variable if it is an external variable can be l an output 2 an input 3 an input with default 4 an input unused If it is an output it must be explicitly assigned a value If it is an input it will be used in the submodel to calculate the submodel outputs The third category input with default is rare The idea is that normally the value is supplied by another submodel but if the submodel connected does not supp
207. with default Append new external variable This only applies to ports A new external variable is added at the end of the existing ones Remember ports are used to connect components together They are vitally important in AMESim It is necessary to be able add remove move and set port types Inserting a port There are three important points to consider If you have an icon for the submodel this sets the number of ports If there is no icon then the number of ports can easily be changed If there is an icon you can still insert extra ports but the submodel will lose it association with the icon Inserting a port when there are no ports Do as follows l Right click on the Port item in the Type list A menu appears Select Append new port 2 Port O ntemal variables O A new port is added You now have to define its external vari ables Append new part Inserting a port when there are one or more ports already You can do as explained before The port will go at the end of the existing ones 171 Chapter 5 Reference Guide for AMESet You can move it to a different position See Moving a port page 173 You can also 1 Right click on one port in the Type list A menu appears 2 Select nsert new A new port is added under the port you selected You now have to define its external variables Editing the number of ports Internal variables Real parameters Inte
208. xicon Figure 5 10 The AMELexicon dialog box under the Titles tab AL AMELexicon Ei E4 Titles Build Yarnable titles piston leakage rate Lemin bar Submodel list hed 4ME libhydr HOO real parameter 11 hyde FAME libhpdr HA OD real parameter 8 Hyde 4ME libhydr HJOG23 real parameter hydr EAME libhrdr HOO real parameter 10 Hyde AME libhydr HJUOZU real parameter 8 hydr AME ibhedr HO real parameter 3 Print Title List Print Submodel List Under the Titles tab the results of an AMELexicon analysis are displayed By selecting a particular title the Submodel list is reconstructed to show the ones that contain this title If you double click on a submodel in Submodel list 1t will be loaded into AMESet This gives a easy way to Copy Paste variable or parameter between submodels License viewer Select this item to see who is currently using AMESim product licenses Normally this is only useful for clients who have multiple licenses Note that you do not use a license for an AMESim library to use this library in AMESet For example you can use a pneumatic library icon and make a copy of a pneumatic library submodel without using a pneumatic library license token 162 5 4 9 5 4 10 AMESet 4 2 User Manual Figure 5 11 The License Viewer dialog box Al License Viewer Ed Suppor refuitk CIT Image L CRoman desketudes3 EDaming imaged Rouszel aroussel Suppor refwzk
209. xten sively at some stage sooner or later you may find a problem Bugs may occur in the pre and post processing facilities of AMESim AMERun AMESet AMECustom or in one ofthe interfaces with other software Usually it 1s quite clear when you have encountered a bug of this type Bugs can also occur when running a simulation of a model Unfortunately it is not pos sible to say that for any model it is always possible to run a simulation The integra tors used in AMECustom are robust but no integrator can claim to be perfectly reliable From the view point of an integrator models vary enormously in their diffi culty Usually when there is a problem it is because the equations being solved are badly conditioned This means that the solution is ill defined It is possible to write down sets of equations that have no solution In such circumstances it is not surprising that the integrator is unsuccessful Other sets of equations have very clearly defined solutions Between these extremes there is a whole spectrum of problems Some of these will be the marginal problems for the integrator If computers were able to do exact arithmetic with real numbers these marginal prob lems would not create any difficulties Unfortunately computers do real arithmetic to a limited accuracy and hence there will be times when the integrator will be forced to give up Simulation is a skill which has to be learnt slowly An experienced person will be aware that ce
210. y The first port requires a linear velocity in m s as an input and computes a force in N as output The second port requires a torque in Nm as an input and computes a rotary velocity in rev min as output The displacement of the rack in mm is calculated as an internal explicit state variable Other information required is the radius of the pinion in mm Figure 3 1 The external variables of RACKOO a pev min 2 rig A simple modification can be made to RACKO0 to produce RACK50 which will calculate the angular position of the pinion 32 AMESet 4 2 User Manual Step 1 First you use AMESet to load and examine the standard RACKOO 1 Start AMESet as follows Using Unix Talk to your system administrator who will show you how to set up your working environment so that you get access to AMESet To start AMESet in a suitable window change to the directory where you wish to work tutorial for instance and type AMESet Using Windows Do one of the following Select AMESet from the menu Program gt Imagine gt AMESet produced by the Start button or Double click on the AMESet icon on your desktop or Type AMESet in a MS DOS Command window from the directory where you wish to work tutorial for instance The display shown in will appear It has been deliberately made similar to AMESim but there are small differences in the display and AMESet performs very different functions The main display area which in AMESim
Download Pdf Manuals
Related Search
Related Contents
Kensington ValuKeyboard HDX SFSD1-500B3IW Use and Care Manual Deutsch - Schuss Home Electronic カタログ(PDF形式/ 1.39MB - ビジネスにパーソナルに、いつでもどこでも Guía del Usuario VGN-TT100 Series - Manuals, Specs & Warranty 女王に関するし,主』 culture - Olivia Beasley NutriBullet Manual MatchMan Users Manual Copyright © All rights reserved.
Failed to retrieve file