Tiller Introductiontophysicalmodelingwithmodelica

You might also like

You are on page 1of 184
INTRODUCTION TO PHYSICAL MODELING THE KLUWER INTERNATIONAL SERIES IN ENGINEERING AND COMPUTER SCIENCE Oe EERE rome %* awit fr Nh Cet nd Sh Amer ‘ene Gu wae Brom atic aut ome sae BG ce capes brary o Congres Ctaeging im Paitin Ds ‘ier, Mit. mdi yl ming wih dee Mc Th site ingame 1 01925-7367. pape) Scene mt Compt) Tl, (ar69.c6s 7352001 ousssistaal opyig © 200 by Kier Andie Pb Seon Ping 2004 ya stare Cyan AB ‘Sila aod Ter svar aes OMe Mier Seta re apf a ie ro aid Leet or wns pms ps Nee Primed on te pp, Prine ae itd Seo Ameren Contents Lista gues sto bles Prete Acknowiedgemens aa tt 2 3 i is M6 The Modes Language INTRODUCTION White Mol? ‘What can Models te wed for ‘Modeling formate Moses Str ary ase voila ‘Sema, 2 DIFFERENTIAL EQUATIONS u 2a 2B 2 25 26 3 3a 33 1 35 36 Concepts Dir eqations Pyle pee Documeting mics Langage fdas Probie BUILDING AND CONNECTING COMPONENTS ‘Cones Conese ‘renting connect Sd components Defi bck ising rutin components Language funerals SREESES SELESSS GSSSaun 20 Summary [ENABLING REUSE 41. Concepis 42. Bapletiagcomionity 43. Resale bulla Boks ‘G4 Allowing repacenle components 43. Other reacts ener $6 Lining Restay {7 Other enone ‘LS Langue andes 49 Probleme FUNCTIONS SConcepte 52. nrodtion tine 53 Anlerplao fanton 54 Multiple tam vee 53. Pasing records apa 56 Using era ebro: 557 Language fndamenals 38 Problems USING ARRAYS ‘a1 Conor 162. Planetary motion: Aaye of onpaits 63. Simple ID hea ander Anas farbles 4 Using nays wih chemical systems 65 Languae funerals 66 Probleme vBRID MODELS Concept 12 Mosel gia! i 13, Bouncing ba 1 Sener modeling 75. Language undastale 25 Problems EXPLORING NONLINEAR BEHAVIOR 81 Cones 82 nies! de 83. Backlat 84. Thermal properties Ho 1 12 155 135 te 166 8 186 199 9 199 19 ms 1S Hodge Haley nerve cell adele 6 Language tindimenals 7 Problems 9 MISCELLANEOUS 92 Atmotaions Put ffecsive Madetcn 1OMULT-DOMAIN MODELING 1 Concept 102 Comeyer ssc 103 sien etn ste 104 Astomotve iary 106 Probes 11 BLOCK DIAGRAMS VS, ACAUSAL MODELING HL Objective 112 Block aga 13 Acasa appro 14 Summary 115 Problems 12 BUILDING LIBRARIES 121 Objective 123 Chsenicn 123 Stare 125 Documentation 125 Maximiing es 126 Moximiin robnest 127 Storage of Madea source cade 128 Celene 13 INITIAL CONDITIONS 133 Using atts 14 Sco lation 135 Inalioton bed on asia pe 136 Canlesoe 41 Objective 20 0s 210 218. 2 2B Bs 233 a 5 28 Fr 2S 266 m m 7 m9 ca 25 20 26 vil INraobUCTION To PHSICAL MODSLNG WrTH MODELICA 142 Us equons 163 Avoid umecesny vets 18 Time eles 145 Proving oan for fonctions 14.6 Choosing te proper inegration oto: 147 Telenoes 149 Concasion Appendices 2A Hatory of Modetin [Ad Contos othe Modes angaage ‘$2. Conus othe Mods Str Library - Modeia Syne (C- Model Standort Ltary: Connectors Cx Elec Calg) (C2 Block diagrams C3 Trndatioa matic C4 Ratton maton _D- Moselic Stnad Liar: Common Unis Du Timeand pace 2. Rete phenomenos D3 Meshanie ag Thermodynamics DS Hleareiy Dé Physcalchemisey - Modeien Standard Libary Coste F. Mle Standard Library: Math Fnctions 2. lnvene geomet functions 2. Hyperbole geomet fnctions Et Exponenalfancons esr References Index ho am. ats ats 36 3 is = a ey x1 List of Figures 2 3 a 0 3 a5 26 2 3 ha 36 2 3 si “Tibia ok a wats uater be ood ooking inside the eine Sexton rena rma sole Pr cone LC cet echo, ‘simple penta Sotton fr @() gen E22) = 0. a (0) = 0. near and toner soon for (ven Z=2, (0) = 2 anda) =O, otage espn of adel ie ‘Twohaie unk file with iu Solon with nil condone 200 and? ‘Avice ody diagram” ofa Resteeoe Schema fr Rc mode Example 38 Pomel wt plan Contoleytem mode sng component rim Mode. Asigle postin 5) ‘Aseria ems ‘hedagam view af Prconerotlex Picontrat ier malin : Prconteolderananotor nadeL Sie ty ie compan of contol. Schema fr Example 410. ‘Outer snug Test Piccewie fr 1 sean- 2 ie » a a 6 ° 6 n a a 36 33 é 62 ea & 6 6s 69 610 a 7a a 15 1 9 am a a a 8s ko w s9 ‘Simulion res fer Tost Completa. ‘Simulon results fr Tost conplentave2 Seren oes nly arate by grin oes Sinaaing the mse fhe Ea nd the Moon for ‘gposinatly yen "Heat vanterins one-dimensional | Sohemat for Conduct snd madelin Exanpl 8 Solon fr Hobe! mse ia Example 61, Schemalctor Conduct inghodiiehconvest ion, shown Example 7 Saon ret fr Ht cn2 mol sown in Eaanple 8. : [Comparison sey stat oon to tProben. ‘Vismlizatie of be Oresontor ection. Ono response from the Oregoater cn Diagram for toguccaeuse model in Example 4, (up silsfom Logsecireus® mol sown in Baample 74. Diogamferiogices rout uibagimalchows intsample 76 Gere tenttnaiovecccititane | pu sigs rom togiecirouseNsentag.e = Behav ade Bouncingben 12 (ur seor bent sysem, Pefoanc fo (10) anhigh ht) gla om tele with ea sense. Compares of SampLeti deen wih el ase (Comarca of Quant sedsenvcr with eal ene, (Conpurson af Perodsensor wie cae [Comparison af Count snasenaor wth ia ee, ‘Geto mode! inet day. ‘Cameras charter til de (Camere characteris of el de pled panera ‘Schematic ofa» ACIDC power pl. Volpe sponse of ACIDC power spy Force dopcement characteris fos aca, Becks schematic With wo ei. ‘Baekin schemate with de ie, [Comparison af he wo bach me fo th eased shown i aes 8. and 87. Plot atu) fom Eqanon (29) 100 9 rt 6 Ps 90 Br be se tet ‘61 i 6 i m3 5 vs 19 a 92 196 196 1% 10 a an 8 92 93 oa ox 03 04 tos 107 ros 10 io 112 tous tous ro16 tos 13 ma te Fes ‘Temperate deibetons in S015 tying foe ie an one property moses Nerve cll sepnent them Dynami respons ofthe eve al. ‘Creag carers ofa il Zee dds ‘Simple page era ‘hace fp ia Example. Schema for penis sto DDymnla tending of HTML documetaic for the ‘PeoTaniee mde shown i Exaile 9:5 Sehemate forthe omveyor st em Schema fr te eae rate Schemas forthe someyo otal Schema fr face, Comparison odes sant bhai Motor voage required ‘Setematie forth ouee od Sehemat forthe Paenace mode ‘Schemite fo the Hochantcai thermostat mods ‘Schema for he Digital Thermostat mode, ‘Schemas forthe Mermostat System motel, Indoor nd Outbor epee Packager est inside te inp Lea sk CCompenens of he Be page ooking inside sn nv eno der ooking imide 4 eter enn. j ‘simplistic ve ped etemion Content te Chnaeiepckage ‘reaing eile mods “Top ievel mode fer dynamin ing Gourde planetary ger wi one ace Plantar gear riven by th un sar Block gram of planetary gear system Piney gear ith tional moan Poste feanddresor arcu forth ansecy package. : Compare ieineen na-i o)ai btom) Comparison of inion ne ud sf ‘ema ger ans En 25 ais ay Po m Es au as 2s 29 List of Tables 1 SI 61 62 ‘Trough and sre ashes fro aris domain. sample ants ype Madea pes + Cpe, Modeica yes #8 FORTRAN? yes Buln feon fo arya Mota. Soir system daa. Dice bhava ai, 5 108 108 15 155 List of Examples Mode of simp endl, Mose of penui athou ie singin. Mode fora RLC crete yaa syten a tw ais model foray ccc esie ‘Rmodel fora etal expt: ‘itl fora cal ndctor 35, Atmel fra ata 3G. A made for lect pon 25 Antero uc RUC cca in ige 3. La REcocur wing MSL 39 single coud syste, : No Gort eas sien 5.12 A Blok lh ams wo semis. 313 An get block, 2314 tor ante din 215 A ote boc 36 compen ated coal jt nde fot Souinhgwest ns 2317 Commoerand mechani 2318 Onesdimesonl atonal coaneiae 1419 Rrcatona! podatn meet 320 A eel beang 321 A Spe pedal ea| 32 Aopen ih mail na 41" Bednng a common ste mas! for ooe pot exis 42 Modeerseaiacar ig odors 43 Sours code rib conser mode in Fig LL coat conrating smote 5 A gene contr ne Z 45 2 Beoperionl gin coal 15 Aisa proportions iret i cai nueeesuaaaaetessuEs 8 48 A gtem coining come and to, $5, Assman conc ng rdetoe ‘Ho Aneampe of how seca eval compooens Rope ma 1 A foto tings rane aay fee | 22 £2 eobte deine tanto ‘pecs einer ucton, $4, Evaluation ofa oar td is dine 55) Catena he Sum of see ne wanes 56 5M wrapper incon fora € soon 3y Rice cg Fon Ra sh fray preiena: 62 Bete commodo a ip by pens (sing vectors 63, Mode frat fy ine ineasiad pas ‘Minion to eset provisional oc. ee A grant merce mode Eneipstatng the rasta fos acta (Geng ary sysem ‘peg A, St gaa of aise tle Egan Conscr fr hea utes ‘Trea confucon Beal. ke type Soy ii, ‘red wih conc hes ‘Hearse in condcing rod wh Woy eos. ‘Atel of hems! omen jin spe ert tater problem ovis cocina eso ‘Acondcing rd wing he Thema iy ose of on anda Mode afr pte 73. Mode ofa gat 14 Made ofa cleus tet Ain or atic. 75 Mosetnglag in iia sa : 16 Ima ag orgs 12 RNontetent tonne 18 ee” boaning ba 19, ater “ite boeing ball “Ho Sete cl esrb yi ZL Metswement wl tation TE Ine enoting meassemen {E14 era cotng approach HY fa nee : ace sing baci sl 53 Cottle elk ode seseseeser Lin Exper ‘A general ermal propery mol ines, ‘Specie hema oper mots ‘sie lcs ‘Avod changing tom si tw ‘sing fancton o deosibes vi eld Sees er erherer sacteanta snort {ing acttons for docamenton a wing this book my goats to deena ho easy sf an fn the rodelng of phys eyes can ePrints snag Bt compat ‘ates for hat irmor iret han snag he tar of se ‘ystems Thee "seal sytem” fr fo te behave of ysis sed ‘ols found arse may dcpies (eg, elect engineering mechanical ‘inerng, emis. phys). Sich systems can be ented by et we ‘Steamenaon proces (eg, nt bw of armodsmamis and eonsetrain| ‘tia Tis book wil dsb how the Mal modeling Isevge eas be ed to dese the ehion of py syteme Models ca bs wsed Tot ‘sige rae of spation fom snl stm with cal few depres of feed ate wy up o comple tema of lage networks resale ‘component, “Theft pat of he book i focused on rsicing header tothe Mos ice mode language. Te net nience ou be some with an ners of ti pyses an ales, an Ie noting 2nd m0 noulogeof Molen ‘Theft ita cover al he sof engage ‘ng simple examples and eae he ede bein sing mcd aM ich later fn he ips of the bok sats wth an overview ofthe lngoant conceit ner ladies. Whenever ane termis inode {tl sper alsd an sino fr wil be ned inthe sian. ‘The overow i thn flowed by a srs of exanpies mea 10 raually ince Moles fanconity el a xamples fan importa par the leaning proces. Thave ied 0 aad sing comsved examples. a ft, ‘any ofthe eames come from rea werd problems have ensured. The “Stiony with examples that hy o ot inde mute ha ste ay, bat ater owing” way- Fortean, ay chaps ince {Language Fendanemal seston which temps forma a ft ‘INTRODUCTION PHYSICAL MODELING Wir MODELICA ooceps itedsca by te examples. Reales may el fe 1 skip ove te nec inthe fandanetals secon it et confab wih he etre resented nth chapter, An mpotan oe bo te sate his Bok ot eeh example introduces new concept ner wr, Jo tase that Besse you unenoo he et example fn ptr ll te remain ‘examples ot woth tyig “The second pur ofthe Bok demonstrates how © mos ete we the poet fess of th Media Iangnge. Tis pt is itnded fer pope ‘to at lead nar wih he ts the Modes lngegefcudng ‘isting tse of Modela ad bears wha have comple th fist pa “Thisbook coves wal al ofthe ears ofthe Mosel languge: Hox cet much of the mtr oly rege In aancd spinon The “or mate equ o begin doing meaning! modeling ea be fund in Capers 1,23 and 7, Redes may wish o few the ateton on those ‘hapten it andten coos cher caper ah beome more prof ‘Reais hat ol pone to sntodas eer nanos ofthe Modes at uae tough examples. Once you ave covered the merlin is ook. ‘oa wil egies nite reference. The ukimate source of infra ‘out Mosel the angape pecieaion el. Forth avon Mode fe lagange peciaton nde onthe oation CD-ROM. We at Soper vig gs papa ee oe 1 surmy too ices material that wil have bro ppl a ssl serve oth egaers and experienced ues ying ge te mast ot of ‘ysl stem modem Acknowledgements 1 would ket tty thanking my pres who hase lays encore mycin. Tc tas mtd me tcughou ny een sen {underneath ening ad modeling Ina {wuld so ike ‘oahank my wife, Deepa Ramarao ber Supt ag ths poet ‘The mati inthis book bs beneGted grea} fom he poatFeatng and ‘ec sighs of ing Eimgei, Sven Bik Matson, Hane Otten Dec Ramaswamy, Mica! R Tile, Maria Oue, Deg Brick and Pa This Baki ult on he foundations of the Malin Inguage tl. As sack the mens x Mote Associaton signers te Mali an see sr Append A) dese the cet fo fouling ch a leg od foveal modting language T wool! so lie to tank Hing li, ‘Sven En Matson, Hans Olson and Dag Brick for tier work on he Dela Software sed ding he weg of istok nd forcntating sn evation py of Dye for incon with hs book ‘eaning isnot posible wit people wing toteach, won ie ota tte people have moked wih an ese fom over the yas for al ae lend om hm, hope atte mtr nhs bo inp he rear ‘ou inthe same wa ht th follovng peopl avec mine: Miche A Tiler Eunice Tiler Raimond Wal: Rote Fle, Aron Le Kin bal Anthony Varghese, Pr tema Kim Stelon, Nicholas Zar, Jon Danzig, Daniel Teroel, Jonshid Oastous, Thomas Kethoven, Chace [Tucker Raph Johnsen, Rober MeDava,Chack Newnan, Googe Davis, Willa Tbe, ting Eigen Marin Oter haved th opportuni. ove tes few ear 1 Werk with several very eight and vegetal on Mote related projet, Cleon Davis helped develo he nal Modeica models weds Flrd Meter Compa sien, 1 would Hk t thnk Huber Tomes othe any fon scusions wehave had on preacher thermodynamic modeling i Mods fe, Finaly, Pal Bowles wasmy costo on sever! apes tat were moa, he a gaprs to demoncnt he cli of he Molen sppoach HS enuf neal poet at Foe and subsequent abate o hat Sede een een othe ses. oul tcl by ping tal ofthe open sure Thave wed in ‘ne preortion ef iabook wuld eo siow my apresanen the there of Grace ag as, XEaaes, CVS, TKCVS, WiNCVS, Kai, Chote, ‘Ghosrpt TEX. IMEX, AvcTEX MIKTEX Lis, KDE an Gores ‘potted uf tl the sore ce ining of Modsica moss in is book ‘ete de wit te BX List ge package by Caten Hel. 1 THE MODELICA LANGUAGE Chapter 1 INTRODUCTION 11 WHAT IS MODELICA? Bef inthe eis of modsting wing Modi, et me provide a tee dseiion of what Medics i wy sta developed and what tase ‘Since the ime ofthe compute, madliag an simlton have ben 1m impoctat prt of comping. Intl, dees were brdened With com ‘ering ir tse no syne of onary dfs eae (ODE) {nd then wig code o inept those dlc equations in ore orn ‘inulin testa. a wide ange of negates were developed sind odes sofa uns nd modelers were sl fo fous on the fonmuaion of ‘Serial quo and we “fsbo shel instr for slo. Tis tea of allowing mses fos ore onthe Detar expos oh Folens ane onthe soon mete has cote eer ce the last tee decodes, numero ols have been developed 0 ass, odes in performing siuauons..Some ofthese wer gow perp sinlaion as sch ACSL!, xy, SystemBuild nd Simi Other {oo were developed fr sealaton io specie egowering dose sh lea cul (eg, Spe) malted systems (eg, ADAMS") oe ‘eral processes eg ASPEN Ph), Each ype of ol ais advantages 4 remopuctiw 70 PuSICAL MODELING Wirt MODELICA or example, general pupse tel do ae ret mses 10 apace onsis tat hey may roi the mor to spend sme time formulas ‘memes frat prio, Likewi, tone developed fora specie “ginsringdonin ve mumercal methods snd pl wer ince ‘hich are optima fr that pari domain ute ett th ayo te Unodlerto crete mined domain model In 197, Hig Est pioneer, as par of his PD. thesis, 2 new ppouh to odeting piel syems by designing and implementing te Dymola meting langunge (Elmgvst, 1978. The tse ea tind he Dy ‘moa modeling lngbage sto we general eqations, bts and connections {allow mode! developers fok at meting fom a pil perspective Instead ofa mateatieal ne For the Dyes mpementton, rap ‘ec ad seb alge were ered otal he del a8 prep form for meal savers An importa lesion ine eel ‘opment oF tis apoach caren 1988 wth he developmen of the Pals algorti or DAF index refocton (Panties, 1988), rolloning Dy, Immerou ae ot (eg. Ome, e Maton al, 1983) wee deep ‘ofarier explore thi sew approach to madeline 'Amajr problem whl Sula ols has been ht ods developed ing tne tbl col nt Be wed y anther In 1995, sng Els Ine an eo o ly the spiked lanseape of modeling nguages by ining the developmen ofthe Modelen modeling Tanna. Simla Itai ve teen uneralen by vais her groupe (ee Heal eta, 2300 and Fak and Miler, 109) ta thse elfen ve Ben Foes ‘rimary onthe eecteldoaaia, whe Modeicasvesf be completely “The tsi ies behind Malcn wt 1 rate a moseing ngage a oul express the behavior of mods rom a wide ange of elnino ‘mains wou mig thse mal toa pric commera to Tn ther ‘ord, Modeica beth modeing language a a mode exchange spec ‘eaten. To acempin is pol. he devsopers of prow jee eed ‘modeling languages ke Alm Dyiols, ME Object, Onel, SIDOPS* tnd She wee tought together wth expers om many engiering dois "ocr he spetontion forthe Model language sed oe thei wie ange sf eaperenes| Modes can wed to sue awry of poems tat can be expressed in ems of dfeeatalgeba eqoons (DAES describing the behavior of cstinaousvarales. Theat to formulae problems as DAES rahe than ODEs redo the buden on he moe developer beste fon atcion 5 ‘olen oroulating outs. In aitionohaingcominacas arable, Mosel inde ene for desing the Behave of dst vaitbles (eg ipl signal) Ofte, comeriet rete ec osm both ‘Saute nl cre teivor athe seine, Mode allows uth fom ft behavior to be desc wiin the sme system mavel or even the se ‘omponent oie Models rn popretay modeling guage ane mae a wade anak ofthe Modsics Acsociton wich i rapes fr pulstion of the Malis langage spect preset, Mela f ota 150, |ANSI o IEE sand This ans hat Mol reset "moving tage” in mach the same way at C+ as for aout ede Ia the ab (Ce viding he uo andare id mot pee peopl fo akg ie a be lnguge and limtly fd to « och tte language. Hope {aly Modeiea wl llow asia pth. If a ned ean be dense fo fucinaty not sreaty presen i the Modes Inns, ws cn ‘rst wth he Modsica Asan 6 fatctonlty gap The coment Mossi speciation canbe found atte Medea Aspen wa se heep://new.ode) tea, og Venn of he Mosshenmeieton ‘inesded onthe companion CD-ROM If you hv ever een involved in ge ale modeling poets you prob iy songz hat ede eelopeat i many ways sr re ele ‘oftware deeopmen. ist ike» programing Iangge the parse of 8 ‘Roding lng to escrb the avin of eal ces auger 9 tem A odeling langage sould encourage ese opens wrk ad hep ‘manage the complecy fst asthe became ge Ht sale ous fences eae of components hasbeen crete work a an isi) Tr lvl ce geting sty from ming unto a he component ve fc wring mare onthe ssely ofa complex sytem). Umar his [Esdetoth ty ld ystems ung op down” approche hn atone" apc ‘All snlton sls presented i thi book wore gerd using Dymo (Dyeumic Modeing Latotoy)” An evaluation copy of Dynal is po ‘ded by Dynan Elst tl, 200) onthe companion CD-ROM stat, ‘ears may pain haem expercace wih ing te Nodes gage. > “ucrtnd bow to stuse Modes mode sig Dy, ls red the Srcumentaton ed "Geng Stated with Dynal” which since i ‘he Dymo sofa, Dymo ca ao eed ogee moda can {poe no Sain enema 1.2. WHAT CAN MODELICA BE USED FOR? Modetia can te wed for many has, ining simlaton of eect cuits (Claus eta, 200), store powers (tera. 200, per “stem sable Lasen, 200), vlc yma (Tiler et 200) an jac stems (Beater, 200), Hower, ho et wat nda at Modes ante sed forts traph anexampe, Whe mot he chess ‘he book se reel sgl amples tosh pci langage ers, ‘te ill tt by ging hp of the ig pte” ne setion we wl show Bi ad peso # asta ary of Modeia modes fr snag stone performance. The Kary Was seveloped fr this bak to demons how eaonaly comple sem an te modeled. While he Kt cna lage numberof mls mst the model are quite simple. Beane these mde are lately spe ty wil give us oly a ough esate of how pra’ stone desis Wl Fecorm, The Models olf rcton ae provided ont sompaion {CD-ROM od cscsedin great eal e Caper 0. sports_car Powe 11, Abin peer, Imagine we with pedi the eelenton performance fer a pric sons en desig. nero judge the perforce, we wil mess he ine ‘Maks the velo acletefrom aero o one hued loses er ou pure LI shows our perfermance et which osaes soca se ‘Do otto fotedinothinking the model we ae simulting st eile ‘ec te pcre ok spe, Ts ja peel ew ofthe robe, gue 12 shows what wo fii if we ok side or spo cr ode, Behind the sey, he soca mel nce moss the chs neon | fd engio 5 well a sig ser ht dees when fo ange ge Behind lof tes images we bt mae (Le, the nage homes ‘et ed tel ie what he mel epee). As we sale ev {hs view of te spat car gies deeply mp imreson, “The engie mode fr carson carson of many component ia Figure 12. Use openap the eine mel we can cach the or nil eying (stownis gue 3). Agsn themager fengine cylinder me pape aed tothe odes so hey ca bey ete a engine cinders. Beh ech tf thee pistes ete scat of the open wed Y ode 8 Indndal npn tinder ewe ope up neo tee etn, efi the nner eel com poet mel shown a Figure 4. By moming io each the aio "del shown sof, we hate goe fom the complete vice lve (shows In Figure 1 al he way dow o mel of nda omponet oh | ‘signe ves (own in Figure). The abity contract ach erachiee is cna fee of Modes. Instn, be ity To alae ral representations fre modes ac we have sean hes gues, aso ate Pode by Modsiea. acho the gapis shown Figure [represen 8 component nove ‘ne fnetion of an indivi egine cinder We cant "Zoon no tee weg ene riod case they represent te smal pices inthe eye I some, ey are he “ons ef our system tis portant overstate peer ae not magical primitives ht jas happen come wits sftare Fackape we tid ob thi ode Io fc a hs component level {at we tm eu atetoe evay fom all te gaps toward tee sbjst sf is book the Mocca modeling lnguags. Previn, we have seen hw the Modeca meeting language cn be ed desi ices of mene. lthe nomic", ean so be sed cece he eve each ofthese conpnens. The reine ofthe book wll rove al he rece) inform obi sich componet ani an enormous ait of tthe componente engineering Soma Bulg models is fa, tu itl we wanto se ress fom uch mod. els When we rm oar selon we fn tat te spr a del peers inthis section can go fom zo to 100 knees er hori 688 sens gure 1 shows seer diferent peer of information recorded dng he {St Notee how he rarsmiason gar changes a diferent eel speed. We an lose ho the engine spe ineases up ul he tasision sit ‘then rope aun. Tes aretha finale een et fo tr snulston. Oe asl ce of infomation value ide mild Pressure rapped mas in the etn, actin fre onthe ies, eansison hte esses Studying such sformation can provide importa nih ‘ng edn proces ‘Once ne havea mse! ha ies good esl, he neal tp 10 sak ous "wha I The pos ein oe ace ol inca mers Pie eka nia enn desig etal, Fo example, we an ey spi he engite sews valve ‘mig, itched thie weigh ie adi ands on. Banging these Vals we en detemine he pac enh of these parame has on veal ‘sem performance Remener, Model ie & domo-tral mdeing langage ws for eating noel fom nety any eagineting domain. ‘The render of he ‘rok shore how mole rom min ter enpnerng Soran cane eed ‘tng the Madan modeling ngage, 10 wrmopucrow 70 unsicAL MODELING wr MoDELICA i is = lhe Fone Saori tons gr 13 MODELING FORMALISMS Before we sam dicusing ho to ase Modelo develop meses, les take a moment ro alk about modcting in genera. Thee re many foals ‘sed for modeling continous systems An excell overview of fee ermal resented Ast tl, 188, Mate sport of te emmon spencer 0 mel In engnering "The Si cal lok Stnprm oieing sn he ber scale cca ting In bisection tne wil disease Hock grams an ctl formate 0 ee andersand the diterences between hem 134 Block diagrams ‘Using lek dagrams, system is deed ie terms of gute: at se Enon and qe: at are unknown. A block dagram const of ‘Simposents call Bock, which bet kon guns compe the ‘known quan. block sara of Proportional cotaler iSshown in Figure L es et meg ect elf ig (n te Ie side of Figure 1.6 are he known gues he deed speed atl (Be act motor speed ad he eed ese). One ah sie of Fig, the exque aod fo contol he sya scone inbetween athe ois whieh dsr thecomputins Ding eto In this example, the difeece bck taketh Scie wed sad sped ‘nip neopets at an op th iercce (ete er. Ove 3 ‘lock then kp the apt iference y thea, Ky The eld spd ifreoce pasted trogh anther pin Bek scl Wy an inegr We compat be enrol ogo by sig thee ie gin rhs “This arose modeling ir oten wd when desing cnt! tyes Fer example, too cha SiuliakanéSytemBulé wets apne. A boc agra sa stra way fexesung cota system dian Home, ‘uch lags ave te mitons we sl deena Caper 1 132 Acausal modeling Desciing stem or compose! beanie tr of conser awe is mfered to abacus! mang With aval orl the Ie 20 ‘lc specication of soem np sl caput. Ite the nae ‘waton of components (2g. O's a Tra resister) a combined ‘onteroio equations to deemine te ove yet feats tobe {clved.Forexampe, when malng eecrical sytem ie he cu shows InFigure 17.one an use Kia care le (a conse nw), | Sts ht the sum fhe eareat fo acl ade tien, Bo ‘} mt te 26. Toe applica of comer lame eit er. 3 12 merRopucTON To pinsicaL MODELING We MODELICA systems of eentaalgebee eguatons (DAES. Dymola and Saber re ‘wo examples of tos tat low scr! ormlsions A : | rc owe Uc dete 1m oder to ferme acts! del, is wel © ent te vow vorlbies wo the acm vals fr ibe component Being tole In ener the arnt trl represent the diving foci the 5st ahd ‘Re rough varie repens he Now of Some cased unity. For an ‘otal th velge he actos sasiahe andthe carent the eg Savin Note hat he prot fhe hough vache ad th ats arable "ypeally has he unis of power ce, Wats Sa), Table 1 suds Seve examples of tough and acess varies for diferent engineering ‘min Ts a Hae par | ote ana ie ne domi 1.33. Farther remarks on formalisms ‘A we shal demons in Chapter, blk diagrams ae comenlet for ‘oto stm modtng ed acu maltose coment for pgs Tannen vodaion 13 sem modeling (ey plant moving). Na oly dos Modeca supper bth hse import type of dling, bt allows Both of bem Be aed Tope 14 MODELICA STANDARD LIBRARY in adton to defining the speciation for the Modelica Ingugs, the Mods Asvaciton so publishes sandal May of Modes model. ‘This slo the Medea Sand Library or MSL) i arabe ie ochre The MSL. was dvlopd so tht wie of the Medel language weald hve to ceat tern bse models for common modeing domains. ‘Throughout ook, we stato ty deelping Modes del ro sch ‘o demonstrate te finden of te language. Then, ep ou sar ‘mole hh lend exit wn the MSL ni wa, cn cover ngage ‘inden ad dels sre he MSL "Kopi that the MS ot alto of lack bor mel which re tured nota. Instead, he Nats representation o al te mel (Site viewed to bop ods xa what bari modeled, Thee ‘modes ar no ire than ay er Males models shoal be aud the wtle ie models coined the MSL-ae wef you ae not eed se them ‘Whe ding it bok, eco he lok fr ue of be MSL. Tes an ‘cay sngnzedty nding formes tt besin with "Moda icn”- All ‘ichetlestelong the MSL. Forex be pil ype fede} ica Srunite,Yoleaget dined ia the MSL, You sho inept is mae trean “Voltage iste dtd nthe STunsee package read inside the ‘Model ca porags" The package saci of Medel vais ining {he MSL) erica may contin umeros ested packages. DO te suite occ mach longer ames ie 1S BASIC VOCABULARY "The Modeclangagespcieon sari estuary fo descbing te elect the Mode linguage. Whe being igs cesar ina formal section, int alee god in earsing marl, Fr his ease ‘ebook wera simpli veal Tn tbeemalnng chaps be following tee 6 vmmopucrion 70 pinsicaL MopEuNG Wt MODEL rndel Aodel ia tehwvioral deen. Fr example, med ofa esto ts dst ty Ohara, The mde sa dept of esse bario, ihe esto ise. note weds, tis importnt separ thee of ‘eis mol he, V = Te Ry fom the rsitontances component ih ‘ier values of eine) you re falar WI oj ened opening 8 model analogous 10 cls component A ciapoaet is an sae of 4 model So, fr seen motel Te arevtr moe, eae nance fe. theese) ol be subcomponent A sabcomponet i wed over component which ae enti within eer component, ec example, eit mig beau ersponent of ater component ike an etic: Patbemore tb ‘lea crit euldteasatcompenet af as pane. Sibecmponens ‘ewe wor becca ode, ‘ystom model syste model sa mode hich completely sl coi nee word ites ot hve exer ean di cnas the sie punter of een aun. any Agu fet to hse ens which havea ae (ey the Teisince of ess). In Model al values are ether sal ge ‘Sing or ocean. Frere «any nigh be a sear or an ay enon ‘The descrsin ofl vals, pramees and euton soc sed with ml cle the oe! defaiton. ectaraton Woena component ramet, varibleoeconsot sista “ihe in spt moe ede aber compen), ht sealed ‘ele, ackage A pacage refer to a clacton of Modes mal which are ‘meat bese ageter: Foresman let package weld key Inclode ditions fess capactor and into ae, eyword A keyed es won, sch at mode, at ha specie meaning Ta Modeice. Arsen, keyword re srved words ad can be wed 'Smamesin declan (ee uals) Inthe examples, he keywords wl apes int ‘Use the explanations ofthese term a fren o Dl derstand the oe compe explains ind ook Te osary, which stron Pe 52 inl hs lems abd many move taeda bonk omission 15 1.6 SUMMARY 1 summay the Modelca language 4 om groper, dma-neia modeling lngusge at suport several eet mong formalisms Mod ‘es can teed fo model bth cotiauns ad dace ter and fxeaste mu domain Ray of odes kaon a the Mobs Sadi Lior is aval reeof charge at heep/ wwe ea. 079. Chapter 2 DIFFERENTIAL EQUATIONS 21 CONCEPTS Moca s+ powefllanguage fr descing the Behar of dyamic systems Atte bet fay dl re mathemati equations. We bein xr cum of Molen by thong bom simple sytem of diferent eae tisconbcexpresed using Modsica. The expression fiesta equations isin ct banc example of Model's ches, Sbseques chaps will te tcesingy soles mls wo demons ow me vanced ates tetp mode deed psc yt manage ste compe ed Pome in he chapter, we wil demonsnte how to waite some simple models ‘hic ce rameter contour viable nd eutens. These expt Should prove enough infermation to alow eae f begin creating bei ‘oe simple made Remember that each of the examples ntreduces em “oncept. The fil sion of i choper eve scompebense review of ‘helangage fetes cree ints chee 22. DIFFERENTIAL EQUATIONS 22.1 Equations of mation Let conser the mai ped ike he ne sow in Fg 2. roan ler cod ln we know th the om of he logos abut a xed Poin mst be eq oro. Thae are vo qs api atthe pot poi in Pigue 2: my = mgt sn) en n= mi 2) ZZ Pe 2. Ase pao vere 0 the angular poston late to gv, Zee lng of the eodulun es he mas fhe ena, 9 the acleton deo Eah | Davie xg dst ryan sheet true, Using be tha te sum oe trae bout the pl po, nt Be re, He ge ° ey tyr. mal if) “whch we cn ur edse 0 fe) =~ sino) eo inal ene sipliog assumption we can make, o he tie being sume that # sama wie enn can proximate sn) a. ‘hse on diferent equation comes mpi = —Z0e 2 {Lerusranforn Eqpaton (25) int sytem et-ne cia cerena (2)-(4) = herewith angular velstyof the pend. Given int ses ors and Seine eae negra hn ee of ean Dirt Eeaions 19 ap Moet asnge pdt 222 Modelien model "ample 2.1 shows hw’ can fe Mott eres he eho the endo in igre 21, Westby sing the yer! followed | ‘tehame of ow model, StzplePendulum Nek, we dee he parte ‘eons tha characte cur ode a ella he ales whi pest |noareqsions. The prance se qunr nich rein conta ng Silo tat may have feet vals fe one snus ate (es, 1) The ashes na roem eto quiies wich are auton ane (eg, 0 md) Las, constans se tose quant, ke the scleton 'ogoviy which rule to change. To comple the mv an equat on ‘eeon sree which ples the equtns sown a Egon 2.9 "Nott he prametr quant in Expo 2. have the paraneter ‘eywor in fon of tea. Likewise, coetans ae eid by the oe of ‘Geecenstantkaywor. Sins the delatons of omega std thot te ot ‘gulf by parameter or consent, hey ae asap ot varies AL ‘he quantes we he dscbed ar of ype Roa shih mens ie re ea ‘ters oppoced toiteges for expe) Exanineg the equation moe sony, we ase hat Mods neues 8 bain opertr called ax wich i wed to epee the ine det ffs varible Example 21 desnbes a complete set of frond ednary ‘afeatialequions wih wo oqaon and wo unknowns, Figare22 sow tbe silted salutes of Example 2. "Now le scone he ation hat # ~ sin(@). I we apt seeing» wide range of motion fer ur pedal, we wos ete fllowng Tener sytem of diferent quo (2) =(-sinw ) ‘ape 2:2 shows tat ont asl changes ose Malis md ‘Apr from changing te toda name the oly oer ching ef oe the en 20 aTRODUCTIOW TO PHYSICAL MODELING WH MoDELICA ge 22 Soot he 22.40) = 4) = Hode1 ica. sath infu, we weet plot hier nd none ods fo sal dspace (ch shown in Fig 22,00 woul nt xpos o beable to sc teiferece. Howerey Figue 23 demos ‘ht forge dsplcesents here ia igaiieat dlleence tween hese ‘ow? Moda pain wou ar mn ‘This snle example provide a good famewerk to demonstrate the basic ‘eater of Moca. ge 2 enon nse) Lt 0)» 2.) 23. PHYSICAL TYPES isi modeling inoles specifying enti Retween vais gat tier sch a vge, pres mas, Model ices eres which low so sper sal ype (eg, vlge pesos, mas) and ase ‘hem wih ques none model. To demonste how ths done, wil ails model of a RLC eles cei An RLC cuit oni eso, ‘pwc and indir ad ents nin bien eps 0 ole 22 INTRODUCTION TO PHYSICAL MODELING Wr MODELICA 23.1 Constitutive equations gue 24 shows the schematic of a8 RLC cit. Before we we oar Modein model of i stm, meat Sa ite de Ee equations for tach the compooen’ ne ssem. Une ie pevios example ee lesan of he fueanetlexitons. Ps leu astune tha he volage our, Vamps fom 0 Volto 1 Wok afer ene scond of sialon We et ten wie an exp expaion fr The olga node flows 0: oster 1:43 Now, me conser the intact model The equation forte caret hgh tention rom ode ao me ae a Liew using Ohm's whe cuentthough he sso rm ode bo ode ean be expressed % ww) Rin WoM nly. became trough apc ving age ca eng grand canbe expesed a= a, ten ot ‘By ung Kies caret le, We Anow fa the of the cae gong tec node mat be 0 Thi pew w-u =o ew tain 29) ae a0) tig tsa gute we ve the following enkowas ica the lloning tions % ew ier! Eaton 23 oo aug Ht en Rie ey te ew iy ey tmin 219) inmic am [Nowe it we cult ave smpied thse eanton farther. For expe, ‘om Equnins (215}(217) weno a be curet heap al th op ‘nes mst be equal iy. This woul have elite he ne sl foe Seto ani slopes Forts example, we weal seven eqns a a Se unos to dementia prior! manipulation of he eto ‘ocrcesay. nse he ifrmation gen inte mode suet or su ‘mnipulation ob ford stamina by he sinalator 232 Modelica model ipo? Mod rma ao “TheModslea escpionofthe RLC deli shown in Exsnle 23a te reels smug hic can be son Fgue 2, The mode shown Vea Pere25. eng nmn omet xanple 23 coves eer ne topic sen athe previous example. The fs tferac isthe perce of psc pes Le, Voleage, Sean Resistance, Capacieance a Inductance). At we salle aes, "hee pyc types provide inert iforsation snot he guise ae scl wih (eg uie is and deans). These psi yes are ened in «package called Nadel ea. sunt, Thist why te ysl ‘opeall conan Node lon, stunk intima Tm the equation ston, we see he tue of te Sf heyword. The se of intact called anseexpeion” orbs etample when ee Isles han 1 Ve = O and nce ine see thn I, Vg = 1. The variable me is se epreseat simulation 24 DOCUMENTING MODELS 1 hie sein, we crete a model of» hyatie system and show bow to include documentos i tds, Such doamematon wot ely Begs ‘he mol develope tember bow the mode! fencing he Diora Eautons 25 veloped any ne aber of the molto wndntand exacly what ech of ‘be componces and uamies preset Figure 2.6 shou the schematic fora hyde sytem composed of 180 tanks connected by nea pipe, Foes example, me asume that te ‘aint nk incompressible andes tank ascot ernest 24.1 Constitutive equations ‘The fist sep in compatng the ow, Q dvoug he pp soko he rei he bottom of ech tank. To determine he press we ee folowing equation: Peal whee is the presse, 6 the Bight ofthe fl in the nk, 9 te Seceleton eo Bvity ad te deny ofthe id. Using tis ‘sont, he pene a eto tanks we deter teflon quan P= patty a1 Pe = pals a1) Now hat we now he peste, we ned compte he ole ow e ,tough he pipe, Fer mina ow though» ideale, We ca (Sethe Hager-Poseieelasonsip ame Opla, 97 ani - dt where Phe pres in he nk on tee, Pte pes ean ‘om tbe igh D isthe ameter fhe pipe onset th two aks isthe 26 IvtRoUCTION To PHYSICAL MODELING WH MODELICA yumi iscsi an ithe lng of ep. Noth the sin comneaton forQ ist a postive lve iets Now rm ha el th ak ner Lely, need an equation wich eles the ome fom te tah the pps wih change nl eight in enc nk. Sine the fd Romine exer ean scones te vue of fd owing ough he Fige must ete tame a volume of ld ecnged with ees Te ebevior an be exprased byte ollowing unions -@ zy aio a2 thew Ai the comecionl aes of he tno he eft Ae the Crosse ae of he ase ih ani owe 27 Sen oe combi Ya et 242 Modeliea model ‘ample 2¢ shows the Modes mode ht contipnds te hydrate system shown ia Figure 26. Figure 27 shows th ston ro fo tha igri! Euaons 2 i av fee Sr ant » | etter stunies,oyanisvinccaity rin2e-3) ‘Parmttar Stunite RinenaticiLecontty Ge ip"¥) 7 Ha8*mie —_____J Cmpie?4 Hye pum fon ms sem assuning the et tank staat height of meter sd te acd tank Sans wha height ef2 ter Tasted of ying oat te Hod ca, STunit quis befre each py ‘eltypeas ne din Example 23, meinen chore cet an stevia ST, ang the peckage keyword. Using is approche re ue fe far ower charts for exh yi iype same. Tha of hi 8 a seat aases when woking fh og pockage names. In Example 2c, we en asthe of dense txt (conan Between ching ube goto mak) ssid with he mod and parameter main his example cludes comments which provide aan doc 28 _IvTmoDUCTIOWToPursICAL MODELING WITH MODELICA eae, Whence tcc /" ap ode ee ‘Sette nis contre comer “Theron en beter cane th pres examen turchogri toh py etn The St caeon tne cota sommes eons le ‘itm net mde eso toon en, onneante’ gn epesning ‘ection Ears py ad vesetsen-Conscanter pe Us SF pyc! sna in GL eve ee rns Rs ea perenne omental oe cst Sc it tae re hat he coma pes compe onl pen fete comptes won. stan sre pe est OR shvamica ney. 25 LANGUAGE FUNDAMENTALS ‘The purpose f his etn i to provide & mre compehensie dain fe langoge fundamen dense Wy te examples i this hate ‘This section ncloed for completeness but not ee. Reade my fee fet sip hi section eel they coe wih he mit reseed sf 25.1 Models Modes have bebivor ested by algebra nr iret egutons Recall ure of he nodal eyatd i samples 21,23 and 24. The eyword model in Models ir wed ine the sta el eon “As we hive sea lao examples, the end Keyword (flied agai y the Imoel ames oe he end ote nel? ‘AS seen in Example 2 the defnon of model may nce designe ‘exo provid adios fomaton boat he model, Te etl descrpon ‘ofamode mst e contained wan matching donb quan ast pear dct ater th mol rane, ‘The texal deen for constant rameters, ables er any component declan mus pee er 9 the" whichstsedo inate te endofiedectarton, Whecomment re {efor tex with opr sociation oan pro he Modeea sore ‘eral desriponare ey anole wt speci deiton. Ts nk ‘specif delaron alms tex dexrpon tbe wed in rap er Ines or stomatal generated doeamesation, Inti chapter, we hve Seen mode which comin constants, parameter, ables std eqetons While tte ae ober igs & mel con, Seamer ea py maa nce Dien! Earns 29 ‘tee rth base clement aed shoul be scent for developing simple poses 252 Variables, parameters and constants 2521 Declaratlone Asso my hve ed rm the examples in ica he delaton tery quit ey varie, parameters td eonstan) eqes © Ye (eg, Real or henge) followed bys mane. Purhernoe, cach dele tay inctde ua quan for fugu (eq, "=32") anor esate te {Setcitd wth te quanti. The nd of the deciaraon i Inde by 2 ecolon 2522 Types 1m ours example, we wed the bul-n type Res 0 represent Ati soit ven Models provier hee atonal bln (pes: Tnceger, Bootean ané Seng Teaton te bal ayes, spose create dered ype. Deed ype ae specaletions of th ttn types. For example, he Gere type {ange sown ie Example defied in he MSL lows Derived per provide more specie nfrmation about fe ua. This information is etal for dcameation proses (what pi nis fe soci ih given pamete, lt coneson aod in tome css ven some smc aaj eg un checking in expression). The mos Soman ae sie types inthe MS ae comped in Appendix 2523. Vari ‘Any declared quai in Moi has a pee vray, By deal, aul decied gunna sued 6 ange a function of Sun tine. However ae aii qulifers wich an be red onal ere lee of aii. Ini per we ae ntroaced vo such aie, Constant and paraneeer Boh of tse gues preva he ve of Sua om changing daring salto. Despite fat ht both ae ‘ett inthe way thee ae two impor diferences between constants Salpeter Fis once eine within sods const ote to techangod.Fcthiseon, the apical brite fo some ols at Slow jst o const (een dips them) In price, his means thecal way constant canbe changed isto modify te soa cae of amodeL ‘The eter derencehetween constants and praca sha he dels ‘fa paameter may clade an xpeston or he a ofthat paneer at 50. IRTRODUCTION TO PSICAL MODELING WITH MODELICA he detain of conta mat pclae an eprom for he alte of a costa fo esple gin Examples a2). "Ter ares varilty quails bt we wl css thos inthe coment of sabexquent examples 283° Expressions Fr the mos pr, expresions in Model loo sia to express in cater computer lnpuges. Ins wtion, we wil cover the base (fs ‘preston wedi our example oa 2531 Bale expressions In Exarople 2, wes ou fet we ofan expression. We compute te secvive of onan t= (g/t) ste. In this oe expreson Me we ‘he muliphiton, vision a uation oper. Moc set the tnd / operator to verse! sito, sabato, mligcaon ad ivision, respec. Furbermore, th” peratr owed to ees og am exresion «pow, Fo example, he expeson (xe) repesens the sum of and rated othe oer of =. Use ofthe” open an be Seen Example 24 in determing he © parameter ‘The prnedence of te erates" /, ad tps ef pretest se Sn ste "As we sl sxin Chute 6 the +, md /oprtr cn be pli toaray (eg, ves an matics). The + and ~ oper can te wed oa ‘crit to sry ofthese shape. The * an / peas can Be edt ‘liply oc vie a say by a cla Ftermors he» operate opens ‘he inte product oprtor when sed Betwacn vo sas he apo shape 2532 Conditional xpresions Condon exesions ae expressions which eau 0 cer teue of {eslae. Sach expressions eh elon oper” “and ">=" 10 epee ently. equa ss a ess an o ea ‘oper han and ret than o ful wo elon, espectively ust 12 With basic expressions, cononlepesions In Mote se smi ‘dkoglexesns inher computer angages). NL ta he" eo" operators contr te plied to Res sable, In Example 23, we sa bow the “>=” opera was wd 1 dteeige wen he imation in deren I Sco. Condon expesions ex ‘be combined usig the or and and logis operate. I on, te not ‘perfor ca be sede egate he vale of conional expression, Fal, ‘enses en be are tex control he precedence he oper Dien ations 31 2533 Function call ‘The odol ica. ath package inte MSL ince ny sf ection (cot Append force a). Forintane esa bw ther fcson ‘winded in Example In ase wherefore orth on {eguent th ages ant be prt by commas. Chapter Sess, Intl, bow to wean ake fasts 2534 sng erpresiont In Example 2.3, we sw bw a sop vole cul be dened wing an whew cond.exps sa codonl expression eating 10 cer tae | false. Inthe cae where the contol expresion evans fo t208 te ‘expression eats to trwe-exps Ifthe condonalexeson eats to false, he eexpesonevats to Eazae.expr- Among ober gs, (hss comenint way of epesoing simple fonctions and dicots, Sich expression ante we apjwbers oral expression canbe ied ad ‘mayen be etd on side mae For ange ep col be expres (hing expo fom: 254 Equations Eich ofthe ods in th chaper cota an equation. Ht iimportat 2 recognise tat te =" oper n Modes der not repre assignment Tnsten, be "~” operon Sees rato tetween several aes ad does ot neces tobe the oe Inte, n ution exes ety been to expressions and has the “Tis is important esate mean th moe! developer ont eqie © ‘nape equates gt Ber lf igen frm (a ak which an be ‘een et once comples systems eifrenta agers equations ive) Infact, he oquaon sped in he axiom a be ay embinton of alsa and feel eunons. For crampl, conic he Tellovng set fenton: 32 INTRODUCTION TO PHYSICAL MODELING WITH MODELICA where time ithe got slation ine, Wf Modelcs were «procedural [Enguge like € o FORTRAN, the item! would sig a abet tthe second atement wld verte value wih ae vale. Ts {rbeenine nthe languages he = operates ied 0 repeat aspen. Te Madeca, the = ose equal elaoship and te == repens the operation of signet” Asignment ae nat alowed mn equation. Tnen tay ste node naigorsenasecon (sesedin Chaps BY ‘ni posite ta he quo righ be earangsby sao ino he following st of asgnments: ws, Note he ua of te: epee, The rarangeen of tens inhi way Caled mle mmiplton. When you pide eqns in Mole fimlator i fe to perfr sch manipulations. Renee, Moda is ‘deine lngge whch ners tht te model developers cal espasble {or providing the egos, ot sling them ‘Nec that equtos ean appt caide he aqution. Specialy an ‘guaoncan aso appear arto deers, Te owing code agent {monte : noel contin wo vrables and vo eqns a ‘hough cly ce the eqations ppesrin the sae. The ter guaton| ‘Srp in oe declron of ambient. The aly to ieade eqns inthe way can be coven tt also colasig since Soh tation a not ly sped when gacing athe mode, Dien! Egeaions 33 of varal nit action we wl scythe do penta sabe Soy ‘pentoe 2551 The derivative opertor inthe exrssion der (x) the do pein i dt epee he ime lative a teva One ingot etc thal the de eperator fan only be sed on varie, not on exesios. Furemioe, e der ‘pent cna be re ecrstly, Inher word he following gal ‘ty torent te second dere Inrtero reese the scan dei of sible, the it derive mas easigndto a vaihie Ferexample phe 1 SCS; 77 Secon dorivesve ‘The simple pentlam model, presenti Example? shows how hi dane thn aoa 2552 The delay operator ‘The delay peatorcane ike wih eter of tee pune. The fist agua of te delay operate vas an expression, Theva of the dol oper the ale o te exression delayed by sme snort of time Toeamcaat of tine dey eseco spunea peo. only two uguments ae preset the th second agen mt Be a rameter esresin which nos kant futon tine, The long ‘San cxample of ing the day peso ith ed ey ‘The reaps f= would beg z(tine~ dt) +ytime — a) Tus possible as the de ay pera to expres arable dey a wel 1a hid arguments pee reeset te maxim tine deo allowed 2d he scan argument an ten be a inearying expression If present, the ed apuent mut be pratensis the vale be soon | avTRODUCTION To ParsICAL MODELING Win WoDELICA arumeot mus alays be eater has oan es than te ve of he hid 256 Attributes sch dale guatiy (ag, a paranetor or constant) has st of ret. Tse site an be oid et with he ype of he goat rte speci instanceof te quay. Foreampi= In bes semen the sear, quant ty and unt atts we aso ted with be ype Lange. Any dedanton of ye Lenge automatically Inher the aes of Leng. In the second ease he decaraton of ‘reise vale of te stare att iherted fom ype Lenge. An) ‘Sh ajnmen theater p a eclaraon ada macro. Mee (eas cm aise can be fond in Chapter 3. We cone hs Section| ‘sth ri st of oma tes 2561 These tribute ‘When delig avaible he stax ves wet prove a easonube Inia goss Ge he expen of the eed ate for a Inpora| ‘xcepfon. This cn be useful in pele whic inate notin ems ‘equations. n sch systems mop soluions ae possible athe at a ttt cn te eed oben slain i ound ch of he bln pes has a art ale. The defi value for ihe seater, Noe tht he vale of the st as srt for | ype anor when deciingw consan of ht ype Because ech constant Slaraton must rovide ava. Forexample, 2562 Theta” tribute ‘The Etned atitat canbe sed in conjunction withthe art tba, to spect he nil vate for a aie athe st fa wane sation. When the fed ati eC, which eth dean va, he wet tia merely indicts an inital ess or wiles eg when sing mo linear equaons However bene fed aie erue the et art ‘tne the ae th val met hve tthe fe lo. ‘Amore compete asus of how th ed st dca Found HnChaper 1, Din Egos 35 2563 The min and “nae” atu ‘Themis and acai define he nina nd macnn visor ‘sven mumeetype. Tes atts awd to ent whe aay has “ease vile. For example temedyeme tempers we meas ‘emi o abslie ao,so mega ae re om pyia.T net hs ‘namodel the min atte would beste, oth Real an Zeer ‘gpeshe hein and max atts. "These atts ae siya in del development to pee the wer famode fom enteing mow phic ves fr preter a retin Simultor know when ites ound an wren loa 2564 The “quantity” atebute The quant ty atte i charcersring wich dreres he maar of type: In mont eres, he sing cots oe ye mane, For ene In ce eases inelving deed types, be quant ty abate ofthe bate ‘ype (Bvenay nth se ined i Abbi pes ive the quan sty te 2868 The “unt” and “plant tate ‘The unit abt serves aint adie for ape. Asignng ‘aseingto he une tte weet sot pe, wee povied Tora prulr type, is importa th al alae gc or uti of at ‘ype tein thos steal equations ite adel wren with ht ‘Sfumpton ta values we povided inte specie uns th Rea and Integer ypestave he unitate “The MSL. povies ae callecton of pes wih he rope is defed (ee Appendix frat of he mest commonly was ye. The Mode ‘ea spect, which cn be found on the companion CD-ROM, contain es aout te format fr sigs represses ans "m= Fer motes pr second "for ots)? ‘When emerng dao paying res, th aes fo en pe ae orally provided in the pial emir apd wih te unit att overs is possible se leet units en een dats o ayn Chapter 3 BUILDING AND CONNECTING COMPONENTS 34 CONCEPTS ‘Wie eqns area ese pt of model development, i qucky ‘comes eons te tal te equations forthe compan ina pte Thar chapter we show haw on coe ution ke Obs aw ‘Stomatialy genertecomrvion ogee or qsniee ke ery ant mas In doing, spb oy bid page moses ner ‘amponet.Onee aga example wildemoasae ios gue eae. ‘Shih section the cd chop wl acs these fenue deta 32 CONNECTORS ‘The focus ofthis caper wl be ring reuabeconpovet mel and ten connecting toner of thee models outer o frm comple eee. Imrie todas the connection af compo, we mast des 2 new ype of don cle ennector "Tetest pial aalgy ofa comnactor ran ll plug. The nian tag of eles pls fat when you plug, for example, television ino leit elet, you canbe sre tha each eI the pg wl comet | the apropte miein he val A connactor in Mode sees te sme apse matching he ppopie ares om cometrson deren fomponee ‘A connector sion cons vibes which escribe the itracton teiweea components. The allowing is sample comector defnton: 536 _1erg0DUCTION TO PHYSICAL MODELING Wir MODELICA ‘ess by setiag he atopLayUnte ate w te desis physic! unit ‘Only the oat type isthe dtaplayOnie ate ITatoel as nt comerson caption osc ai comes held ‘te sones. Foret agu potion deed inte MSL 5 lows “This became few pope tik antes ine of ans, For eneing da rasplaying rests oat people would prea se dees insta eran (Gereoltons pruned fr pe second The dbeplaynit ‘reindeer he pled unt for pre rcering Sd post proces ‘Tee dhepaytnit only hv aml he ol you se wig eipores0 comer, Insny abe nt atte wlabays inte wh seed inside te mel 25.7 Physical types ‘Secon 2522 decried how ne, mote spied yp can be created ‘rom te bala types Theghou as ehapter we have wed a vit of pigleal ypes (eg. outage, Velocity andAngularAcceleration) "Te main advrage of tee specail types ha thy ae Beer te seshing he ate ofa ive qurity tha epee ype Rea. Incomes ‘models it maybe eifeut fire ou te ps epe of sme uate {ie rl teed rs shold be As we hve seni tate examples, {puamecer sane Light ine a guy of eng o ndctane BY {sng predefined physi types fe iended usage of parameter aril {mich charer. Porters clover naj may chek ese uosteny ofthe units ile in expesions, Tae we of ys ypes i {his way cua improve the aati of ecole a el 26 PROBLEMS PROBLEM 2.1 Rewrite the made sown i Example?! oat physica per an provide descriptive et for he model, ails and parame Pnosumé 2.2 Whe physica pe defaion forego able mper ‘tre and mass ron What he ut forest? Do they hve oper ‘anor over bunds? PRosLen 2.3 There are mary comeraonprinipes we may employ ‘he fc tha el orgs arcund wp maser conser Tov? 1720 explain war bing contre. Dire! uations 31 PROBLEM 2.4 Rute model shown in Examples 21 and 22 fra vere of tal poston and velocities, In each cu, ln omega at futon {Gf theta and compar th ear and norlner ejector. Wht are the ering harcore recone? Prontsat 2.5 Write @ model foro “predatory” tem sng the Lata ler tem futons: 4 = any- pr = why wher reps the predator option and ype the pre popu Yin Suggested ols for model coeiens a= 01. = 7 = Sand 5204 Bude Modeten mode fr th tom ond experiment wit diferent Inia popaation ee” he sli by ploing prey popaaon ‘ers predator ppudation Ponts 2.6 Crue model, snilr tthe on shown in Example 24, conan efor mor) tks coated by pipes. ‘PnonLei 2.7 Wriew Made erresion jor Van Buample2.3 sch har: {i rete) 29 0: 28te % Pnonuen 2 The longitdial dynamic of on ref cm be approximated bythe following eins Yound Brogan. 191) 220 225) 226) here 8g and ar varices representing pitch pitch elec and ange fac whl wand Soe fight dames parameters and 8 sa np "mpesering the eeaor ale Using hse equations, ete modes which Drei the behvin of the bef ding ferent mance (ce tne feryng eletor pasion). Sample vas for. wand 8 ae 025,25 and Tresor 40 perRopucTON 0 prnsicaL MODELING WITH MODELICA 33. CREATING CONNECTORS AND COMPONENTS Let uit by considering fear example. Figure 31 shows alight ariton on te ote eeu shown i Figure 24 Because ew esr ‘ras aed in gue 3, te teh eqns ae sight fees tan 33,1 Equation based approach we meeto write a Models model forthe ptm a Figue3.1 he sane say we did oe Figure 24 the ruling mde mh lak someting Ie he ‘one shown in Exaile 3 ‘One pole wih he Modis oe! n Example tht ti geting 2 il fc ose! wha model ft y king a be auc ode. Inher were, yon wold at ocarefly stu the dein in ample to male represent he sbi gue Auer rblem we ate tring owe equatas mip ime. fi aw for exarpe, oper vice in Example 3.1. Whe wring Obs Taw vice my nose ike mich of Daren, writing 25 ines for 3 complex cet rte andthe proces weal bor poe. FUTENDE Ia mitabe made mast be comecte a2 pls. Lie aking se the conservation equations ae wten cect can lobe a eiousand ene prone ack. Fortes reson, Ie peered way fo model the stmt REE S51 sto se component sed pooch, Tipre detsca.stuste Tope fer RL oe 332. Component based approach ‘With compancot asd approach, we ces asingle adel foreach fhe cemponcats we rite (Le. YoLtagesource, Resistor, Capacitor Sed nauceos) Once thse modes xs we can comet nines te ‘epetr in vay combinations. "Te ey tomodling sing component bed approach ist ik about tbe {re ds agra fora component aby gat (broning er ‘om methane jaa) 2 gram wei dees al Sate infermaice| ‘Suid with acompones an iene posible eternal nBuenen. For ‘ample conser the esr sow in igre 2. We cane tha he esto tas tovolages asc with one each coaecton poi. In atc, ‘hee are caret fling tough ach of hese connection pins. Ey 12 A tetod dag ea asin. 3321 BlctrcalPin Before we can tpin wing ode forthe clei components, we must feet appropri coneactr fortes component. Lets de oe ‘This connec etes the wo guts soca with asingl conection pin inthe resbody agra shonin Fight 3.2. FortbeElect 32a Psm eaecog repent th volage at comecton pit a pests Ite canet flowing io theese "An inert big tote shot hi comet the fw quien foot ofthe cornea. The flow quale ienes qanities at rst smo ‘erm, ata cranestn pot, siyng he pope flow vars lors {mls to impcy generate he comaraton equations ike those ft ‘cl’ cuet a shown Eunos (215217) Ths the et sep Inking sytem noel case told and Denon pose. Typical, Be iow gies apple one deer of comers quan Le: Coren the me derive of charge, hich eomsered qn). 'Now tht we hive deed the conse pe. we can mote on 0 He component models 8322 Restor ‘Ona i dessbes he behavior oa ese Le, vain ep ample 3.2 sows how a Modsin mol could be writen for the = site sbown in Fgue 32._The".”_in ques fe pv sa ay of| ‘eesing te lta elements ofa componeat Sine p son instance of an ‘Biecer‘cal Pin comin varable for volage called vIn this ye ‘quaiy pv represen the vllag esecined wit in ‘Ws important when developing component models owe content sgn oon foe the #loy qm The somal sign cometon for Moo ca componens i fled such at pstie Bow Is no te component ‘Theclr inde he Roa at ox motel te vale of pele e cure ‘ong it he resister fom pn pan he aie fot te cue ‘dng ont Coming Components 43 waa a | ‘eowyie 2 Aa rar aie owing fat he resistor rom pin n, Foes Example 3.2 we cm ce | Fostvevleferp. {wae hen vis rserhann Tis consist With the normal Sig comenion Like, a poste male form eke When spear an pv ‘i Example 42th caret pedo repent cent in Oba law This bce betwen sng pt and naira, However if ‘bean aed in he equation, wold aed woe wen es ine tsi the sg conection for How varies (Le 2 pov ve repent fw inothe compet) Fly. nt at» ela fale of 3000 | ise forthe estas oe reir 3323 Capactr ‘The consiie equation fe te Bevo of nel apc o! a2) ‘a ‘Once we hve writen the model fr the Rea tor, ti ay to imagine bow a model for acaparior woul be ten, Example 33 tho jt sch ‘del Note ha We mst cone fo re these ign ooenton. Losing the mol in Example 3, on might wonder it would pnb we the eqnion er pa fl As we pitt in Sesion 2.551, ts iota besa he da opesor ‘ano: be apie fo an expeson. inthe case of he Capacivor adel ve le his by odcing hv varablowhich epee he vg dierece ‘ros the cnpctr The dah eapacance fr tiscapactor dele 17, 446 erropucrion 70 pinsicaL MODELING WITH MODELICA [pithy tiie crwesann cee reapcteneey ‘Baie Aetel renee paoe nad Inductor The costae equation fr an itor a 2 6 Towle Ai ree mae sample 34 sows a Modelca model for nner Again we tke cae rouse th cae igacomention, Can you seth similar othe Rapistor tnd Capacitor mol? We wil take sana ofthe snares in ter ‘samples The dfs indcance lve 10" 225 Step voltage source ‘We now nena mode fr the og source sown in Figure 3.1. Example 2.Sshov how sich mel cold be writen. Te Voleagesouzee medel ons fo algebraic anton. The st tates what eva dpi ‘Shou the Voteagesource fm omecton point pox The er etn “dase hat he eet Coming In oe side of the compooent mst exacts ing Comectig Camgons 45 tulance te cuneat oing ct he thrid. Unie our revi exams, the Yoltagesource madkl does nt conan an exp egaion for te trent owing though he dvioe a fncoa te Vlge op ares Instead. nex eqaion is proved forte volge acs he ec nd the simulate wil be spun for tering wht arc fearon recess de vlage equation: "Noe tat thsi an dealied volage source mol ad the dicosnous voltage drop might case uo a ome crete or example, ts vllge ‘our were cones pai o capac the fatter | voltage (de ote sep) sould igae a ini cute pe hough te ipa Fer moe ri rate os mig neces ane voltage sore. BY defi the vliage source hasan inal vtage dopo 20 ols sd amps to oage dopo Wa aie I sco B26 Grou [int oround “ermal ‘Empl Ano i ‘Tae st comport model we requ salah ca shown in Figure 31 Ground! The Ground mad e iferet from alle ober slots imodlspseted so far because only ha ine Elect ica l2Sn con ‘ctr In ton. hr ao prunes asd wha Grund model 446. tvraopucriON To PinSICAL MODELING WH MODELICA ‘The only uo equi fo the Gzound model io mt the voltage a te ‘conection ozs. The Ground component model cate senin Bea [8256 Thecrosndand voleagesouoe are gle stne The ference [stht he Gourd adel conan te svlte ape os omen pit ‘whereas the VoeageSource model costa te elatie Yolage betwee "we consecon pints Both mofle il ue te aero nly she forthe caren rough te device. 3327 Civuit model “Ramp? mir mt rR cn 3 Now hat we have writen our componst mols, we an bing hem all toptherto ul sce et ne shown nigue 2 Example 3.7 shows tat he Modeia code for ur cic mol loos Hk. No in Exar 517 ta estore RL and R2 hve diferent wales forts Restotance araneer: We en ee is bea th delat ofthese rears ona | Imodieton (Le th semen conned win parents) change te Vale of he parameter of ach component. Because he elation ofthe ‘age source Cmponet 0, oes Specials os parame (Le thee ae no modieston the desler defied ine the congener ‘ode wl be wed Inordeto fll undestand Example 37 sme explanation mst be poe forthe coasect command. Bese he dl fh onnne conan a ‘covered in Sesion 36, we oly preset x uy explanation ee “The connect command gett estos bated othe conten of he connectors being once. Equations te ener by cons tC eins and Comecing Components $1 Poness ofeach conecior with matig names, Nomi, the connect amma generates an equation which et te mahngcomponens ea ‘achther However facompenen hah fo aii, hr atheough ‘arial thn a exuton eerste ch suns te mating compo teas. SoforourHuect ea) Pin comectordefnton he volar sete tal oer vag he constion pis ante sam al cae ‘nations he connect ot stot ‘sings es, we fl th he connect teen a xanple 3.7 wuld seer the following equstons eee nay (Sips 2 E80 cqaica | Es = Aloe Susie} ths = Rebs an Sar") mine = dpe wie, [7025 F pets Fins = Simms common 9 capi tpt Goes {2 = Ents Minas Raps o9 St tow ont foe ow 5 Staind Cnt ggromd ‘The ons ofthe amet othe connect command it igor, As le oul o 333 Standard electrical components ‘evento reat deo able cee dftons forte cantor and esl components (eg, Resistor, Capacitor, te) ints set, opefly his was isc ia soning how old wp rch components ower, sms ou taal of thi has already een done form This wate the MSL has itary f ele components ik he orponens ‘e cree in hisses and any moe) “To demons the wseflses of he MSL, we wil eimplemene Beane 2.7 wing compeoens fom the MSL. As Example 8 shore, eying We ted is aaale win he MSL. The Moi langage eats te sy 48 vropUCTIONO PHYSICAL MODELING WH MODELICA to include gaphi infomation about component (oe more denis sost [mph nlomto, see Seton 9.2). Became the MSL provides ach [raphe informatie stot each component, sebeais hetht ne svn in pure 13 can be ely eed dec fom he Mosel sure coe* “mp Medet ice. Hlectrical.Aoaloy: mms: Fawiei Rie eiconmae or Sm 11 ot ne we gt Dt a cle i ing an Coming Canponets 9 ote ow it woe wa roid oui the RLC lc his sine Boome ‘wed no need owe an component male. The MSL. cots «xr nme of rede sed etic composes 34 DEFINING A BLOCK we caer Aecl our dicston of he block gram approsh exci in Section LL, Let conser hw suc sytem cold be const n Modi ‘Teck diagram we metered a modsing shown In Figure 3. Tis ‘rem preset the con of retinal (plan) by PL onl “he Pl snore oped sesso dtcrmin he angular velst of the ‘em aad ancl nora sctte The sigal represents the desired gular seaciy which, for example bappens tobe ane wave. These (Serepesens he sped senor eadig nthe sha The conto of he ‘ln ocks a oleate ee a forge signal, wich s aplied oth ‘an model. The respon of the plat model gen bya ase fin, then provides the feedback gn ow 34,1 Equation based approach we reat a model ofthe cont syste sho in igure 3.4 by sip Ting sth eaten, the evuting Modeca mode! would Yok someting Texan 39, Wivhlsaprosch, weld ousevesrewrtng eqns ‘ove and over asin. We can avid hr roblem by wing 3 cmpenent based approach 342 Component based approach ‘nce api, cu gual 10 cere esble component, Thi time we will develop mada which cn be ed ot the stem shown in Figure 34 50. IvrRoDUCTION To PHYSICAL MODELING Wir MODELICA | remotes peal rp.t, 160.0) | fence srnute-aentactetectty 3c0-3" farce Siunite bapangeoeeiciene 0.22 Eel Aspect wll at ny nabs of eter ose consratons Fr hs example, We ‘mst inuedate he conc of» Block. A block special Lind of wool ‘ther exch connector Is cota) exp) marhed es either an Input {xr ovtput. It espected ht each component wil reve eens fis ‘uptewriten inure opt 3421 Connector definitions ‘Bowed Camorra In rer create ou component models, we must knw what information ‘ral rom fe connectors In theca, the frat shred teers ese models is slap doating pie value Foe hs reason. we dele ca ‘omector as sbown in Example 3.10. tng ond ComecngConponens SL 3422 Cretiga sina sgnal generator “Te natal lice ost wth th eed nga velo onl Asin@Q'), The model fr is devng ial shown Exaeple 3.1, persion xen “ompeSAsimei lp 3423. Sammation block ‘Te model fora Suma on Hock shown in Example’. 12 Neha thi ‘sol ncaa o sale atric allow the pt tele indepen (eat Le utput = eae imp + sean imp) whic ese te ‘rosa afte mode. For sxunpl, we cass hs trout Summation ck imo lilnceBlsk by eng one of he sel corso 1 Toole 2A kc os M24 megrator block Our Integrator model canbe seen in Example 3.15. Ther iso bin Ieraton oper. Instea,negals are epson is ems oes thing the der oper In i ne he negation expe Soutput = input 66 ‘92 NRODUCTION TO PHSICAL MODELING WITH MODELICA ig nd Comet Components 53 (an pe sian oats Teich Anise “Tenia up vale fort inet gven by he Sava parameter ‘hichis weds the aarti om Seton 251 forth uf sia. 3425 Transfer funtion ‘ample. sb zepresento offs ner mfr ection ode “The ants funtion charred he following maternal eee: ule) © wh u() pes he inp igen and (represents he pt ema ‘Nowe bt he canton cnn wo carci paramere 3 an 2 [dt etnecenctan ‘ie A toe atin M26 Galnbec “The hiro ain bok represented bythe olin mtn: output = Eo input on “The Gada bck noel apperin Example 3.15, Can youspothe sina the Gan block hos wie model in Example 313 and 3187 isa good ‘ea et inte hab opting sch sims or easons we will exp inte oe caper, ‘ape Airc 3427 Complete contra stem ‘Aisi, we ar able put all hse models ost ito n compete syste Example shows the del itenin ters of component models Fete sem sown in Figure 3. Whe Example 3.16 looks more compl ‘tod than Example 3.9, component hed odes areas o build Bem fey canbe cone grape. me Acoma ba cam nd fr ae ows gee 343 Standard block diagram components ‘Once again webae gone fo rea del of ole oimplement scallion of pdt sea erst inte MSL Remo, the papas a is chapter ‘Etoshow ou how tite models wen hey se nots ‘4 IermoDUCTIONTo PuYsicAL MODELING WITH MoD-LICA 331 Connectors ‘Our sgnal comector isc define sag wo dent comnactor “entins in ocea ica Locke, This bec thee roe eonne tor teeing aad ate fo oa (each with te ability Yo Bale am ry of ‘aa The connor aie allows “These cones deiions canbe fund in he ode ica. Blocks. Interfaces poctage hich coinsalltheconoettfortheNodel sca. ~ locks pct. lastead of wig: fap signa in og can now we the folowing MSL components especie: Using the MSL components seems ke It would eure» gent de mee ‘apg. Howeves a gral! ol woul pally be weed 9 conic sch "Speman ying mole rele sper “dag nd” operons. Farber. we hie aeady see examples wher the spore keyword has ‘bee se oiimize the stout of png nee. “There tome important ferences tween the coat deed in te NL andthe one We Seed ever in Example 310. The ist that ‘he snp gulferis inh ise the ein of he Eno comer ‘ster hana quiron ech Signal cometoe The presence of the ‘put qualifier testa e TaPort comoctercan aly be comeced © ‘tng comet Asa et of having the Anput quer isi, we lint epost of cidenallyforgeting once he gar vile ‘nile mel "Thee dilerence tha the gna cared by the MSL connectors i ‘am aray whereas our van was a scl. By dealt these ofthe eign] try 1 dewey the parameter. The fet hat ga isn ray ee ate tt ein ung ond Cmecing Componas55 ‘swf boat it allows sever signals oe mulled no the same econ Think of ike an ecwosc cable with lie ies nie (eg. anon cable). Mor formation on ing rays Mesehencan be fear Caper 6 543.2 Other cesary Blocks ‘Now ta webave covered become. stu car ateton othe ote ‘oc reed obi oor contalee The commanded enna! velo sas previo represent wing the Stnusoidalsignat Heck. The ral ‘pots Hack in he MSL. Hodel sca. Blocke .Sourcea. Sine which hs parameters for ampli, quency sndsigal fet, The ode ica. ~ Blocke sources package comais a aunber of ober wef ig eer “he Gain block can be replace bythe Nodal ca Backs .Math.~ ‘Gein mode fom he MSL, The Wade icn. Blacks. Math postage oo tans blocks which ae user te algebra map fsignal nf, there are ro models which could serve a repherents for Summation The {is, Nadel Sen. block Nath Feedback ited in fet oop (ie he one we hive in our example) ~The tee mel, Nadel ce. Blocks Nath Addis more Ik o ila Sumnat ion ose bea Allows trary une to be asciedwith exch fh pt sa nly we rege bck which expres lone slang he de ‘dvs of sigmls. These can be fund isthe Nadel Sve Blocke-~ ‘Continuous package On sf ock fom this package istode ica. - Blocks .Continuous.antegrator hich can see at 8 repacomen fer oo previous mel abo call Invegrator') Another wu Black fromthe tame nested package se Model sca. Blocks Cont uous. ‘Teanafertuncesontioc whichis expres ule) dag as) hae) co) SAA3- Complete dagram [Nowe fe lhe pees we oad otal ou contr sytem ng ‘ompovent dened in Nadel cn. Biocka. The alt shorn ise 135. Tecomplte Modan cade orth agra howe Figure 3 Sesh {nBsamie 317. sree ine repr mat ne sroinertteploie Sates imental ‘5% INTRODUCTION TO PHYSICALMODELING WITH WODELICA ‘Novis nechsatn Fonintttg) ood nash onan Townes PN tmelivedee( SI, feegtee 3 we Gia ci 38 EXISTING ROTATIONAL COMPONENTS Let uv tr snple peda model ia Seaton 22 and we it © intodoce the ade} Soa echaniaa- Rotational package inthe MSL. rag andComecing Components ST 35.1 Connectors ‘The connector wie ia he Node. Machanios.Rotat Sonal Ik tea ical ange" Thee ae atl to ern ange connectors Ine MSL. These wo commer te clled Flange a ahd Flange. ‘With tbeexcepton of tel prapbialrepeseatatios, tse Wo eoanecr ate denial. The Models deft for Page. sown a Example 18. Tehaten tnicnagie set ‘Bay 8 Ooi a moe 352 Special models ‘urcrigl model of ape was escribody combinaoa of ty sod igri, We sil epset hse behav y he mode Rotational ~ endui show in Example 3.19. The Feictsonuesedoine motel, ‘Shown in Geample 3.20 wl be ed to onset he peli oa fae of ‘fens. S21 Artatinal pendulum made Recl rom Example 22 ft hero the pendulum due to gait and = mg: sn) + mb*9 9) ‘anpe 3.19 shows he Malia cove frou Ret at Lona Pendutun ‘model, We we the connector deiiton fom Example 3.18 song wih the ‘ravi equations shown a Equation 3.9) ‘Unie or previa pend exam. his model we eed conser tte" ty diagram fore pentlum, Inher wor, weed conser ‘te pony tat ome exe ere eto elas) might ‘Sb cont to he on of he pendun,So, e mut ume a he fm of htt both pio poi seq 7,47 Pe Wt Fe ‘beam ofall extemal tors. “Thera era ffeences between fe Rot ae onal Pend unmadel andthe sine mel we cated Cape 3 The rt ference tha te 8 IxrRODUCTION 70 PHYSICAL MODELING WH MODELICA ‘otedeatcn nach ota. pat) signa =p. ta ange-s connector dts he gus postion othe pen 8 pt ot previwly we fad sed theta torepesen he ane hg "The pet ference Is a te pelos example the ped mas, wasnt sigan Besa me cul aes itt ech term the sem ‘tegutos.That wa poe because we ha te compe set of bebo ‘ypaion. Ths tine though, we cao be sre what ter tems may be Inte (vate acon) we amt cancel he mass et inal recl at the Modlcacomeatin is th the #1 quis on ‘a comectr ae asumed tobe pote wen they win the compone| ‘he blog tT sweat hen trues weld rae te ‘momentum. Soin the acne f gaia pea gree than 2 oud imply an ph peer tan so. We en te hice ely tha we ate ‘wed the comet sign fer each erm. 353 A fHetionless pin modet Prev, eit comer wha lions our pend id with ‘nssurounaingsTheimplstssampin va hat be peodaun was come {0 same fed pie bya fons Bening. Example 3.20 shows a mods Uwhich cape! te evr af ch 2 oT eee, he jt ana ‘ofr earls of he eae nga lacy e poston between the endl ns sroings Pun ond Cmecing Components 39 ‘Ear A ag pend Pin Foun 16 Asepniian sen 354 A simple rotational system “The Mosein code in Example 3.21 secretes cu example fom Chapter? In aldion, Figure 3.5 shows the schema for spl tm ‘muy Asimpe penton | ‘The Node] tea. techanice Rott ional. Fixed mods i snalo- ‘gous othe Ground model in Example 36 (Le, provi a ed reference Fee oter compen. 6 wrmopvcTOW 70 PuystesL MODELING WH MODELICA 35S Building more complex systems are ake - a - = 777 fixed=0 owe Anemone pene ‘Ope ofthe grea things stot having irre of components i the vat ‘mute of combinations hae possible: Sofa me he only Been conrad ‘wi 2 single pends, bt wat we wad Yo cost aya ah ‘up spenders an penumsFigue 37 sms st such 2 stem. The sen, damper ad ed point mods al come fon he MSL. ‘The code ors systems sow a Example 322 feseicn fachanon fatten! ver Ste 3 pavers mie 522 Ane ahi po Note ht te rodeos to pendula pia Exagle 122 ae net. ‘mote weds, modieadon op! may nla mfr ocmponets ung a Comecg Cmpenens 6 Imsde pa (eg, ph. Soh eanve modifeations allow modems be ‘pled component win = rey 36 LANGUAGE FUNDAMENTALS ‘Thi chapersisrofuced many new eas. Lets explore ll hes consti te mre dep 36.1 Connections ‘connector defines information hic toe shared between compo- nts Toee rn Bi on the momber of aases ch can Be dele Innis connector I's ven pone locate a connector Which cons ay of brary bat edie ike te Tart and OutPOre comes Nodeiica blocks, “The comnoct keyword is sd within an uation sto 10 ik” cow seclr icc ‘The cont command ays spear in he equa ico ‘sn beaun cach conbecton ete nat f eqns being peter sch coorectr mst he ex te se ner of omens witha ‘he same names, Furthermore, components wi dese ne mast enpatile ae Section 2522) a low guns can ely be ome ‘her oe quotes, ‘Acomnectsaemeat inde wo agoments. Iter worl connect stamens be of the geera fae wheres 8 are connects (bjt the constants mentioned earn ‘here he conostors sno igi ote sno deen between the previo cones sate! ad Norm, heft of wing cone tht quton ate nen which aunt: qn in one comer with counterpart tease a) Inthe oercooecoe Thescepton when quiver taethe fo qulle ‘plied to hem, Stace flow gute ve early he ne desaies of fensered quis, ommeing hem gee genes on egion which sali iow guts omg Rio rcoret ns). Queen connection iveles le components eg cometion poi in Figure 5.1) Tethers ess the umf te Foe sis ool comets ist culo ame Bally fa eanactor i ever comet ayting hen ‘low quotes int connector are imple set to 20° (62 _rwoDUCTION To PHNSICAL MODELING WITH MODELICA A ton previo, coon can ve parameters ssc with them Suchparamstersaesevlyusel onde beste fone omar ‘umes within connector, Spel consrato sen for uml ide comer Ifsparuter spear ie a connector. he comect ‘tment vers that the conespeding ameter in thet wo comets have "he same wae tt egos pemerte, In tet wor he elwing per : In sunny te connect keyword als tt gue. sy (e, without ‘hepsi of man eo aad atonal generat eqns ppp 362 Qualifiers “The ipa ulfer denis quis whic oe imende io beings to ral. The isp uit nfl fro ifeent ease. is eps {hein vo anybody viewing the soe oe motel Le esp snes thatthe Sper quantity shoal angina onan output sonnei nthe ‘em, More porta conectng wo np oper tte same el of Tehri sno alone. ln sway. the tmpat qualifier eset fres the quit to be comput yan extemal mde. Noe ha igre 3 sens tooo sno at 0 nt canoo be comet oer because "pea tha eg ofthe two pin lek re ennai Howe ne "hm he mplementaons in Epis 3.16 ap 31 how hat i at eh of | the gun oc opt connect 1 he cut of eoter lock a tates inet ‘Therese aos wrinklein he emanic ofthe Sapa qi Is ote o cane! two tu connector tga hey ao i ame [eel ofthe techy Thi i eecsay in cre allo inp igas ote ropazated ito haces ce Secon 43 for m example exh ug) ‘Rea eT aor tien athe a ‘utr and Coming Components 63 ‘The output quire counter tte input que: The output oar inden tha given quanti computed bythe model in which Seti Agathe prose of ds quae to exes the inet of te ‘nol developer nto preven certain kids of eomnetons Le isnt est ‘Scone iopeber vo guns hic oh ave the our gue. “he Flow gai Is efi systems where conser Pencils ae oped (eg. sles e mechan systems). Any quan Heated as 2 Fhow is stinmed at each coeection pot. The foe qi sgeowally fepledo componct with aphycl pele. Curren Powe) hatte {me dra of eons quis eq. charge, energy) By comento, pus vale fora Flo na connector resents a fow nt the ol Which eats the comectoe Nett we flor hi coment inal exanpe. ‘Asa gee le gut spied osconnestor ae eeively ropgaed ino every menber ofthe const, When evloping scone you ed ‘ase wheter ou was the quali o be apie y the dfn: rahe ie of elation: In bat ass, he components a. and ay are consid ina The fuer caer wefl when 3 mnie et oe i be ao ipa ‘or oueput conto Te Inter nei el to foc he contr oe 2 pee decoy eter tape or utp” Pally, ster eng fer placing th qari the ciate woul tet cee aig” ‘omecis wih complementary tpt and outpat quis aera (64 NrRoDUCTION To PHYSICAL MODELING WITH MODELICA 363 Modifications ‘Wen a model i writes, eal wales fr preter are fen provided by the mod Hull "Ar ve have sho ip Example 3.7. we can vere ‘hese ara defaliswhen the component deed. Changes oats, lieth stat, min and unit ates dscssed in Section 23.6 a 0 ‘seins modifeatons Moifestons en be applied components thoaghot x cmponet Ne archy, For esmiplconsder the following example In his case, from he Appliance lve, weve ape a olfition ta esr and capaci inte Chou componert- As canbe seen by this ‘ample moficaoes on need components mace wth ested pais of premises we il atemped to most cps cD fom te ApsLiance lvl ‘ne weal hve overdo th modieton neal ite Cece mode. [Ars geerl, modcatens ina decinaton vay verde meets Tbvet down inthe Merch Hower tere ae may eases wo covered by thre The precise about he precedence of moisten an be fund Inthe Modes ngugespecfeton nated on he companion CD-ROM ‘Anite expe of ere modieaton canbe een in Exanple 32, Instead of rameter, au fhe ps are ssecied wih he Bp nthe ovat Lonel endulun were modified. un and ComecngComponns 65 364 Defining a block ‘As mesons in or cont! seem ena, bLoek isa pei cae soto) wheel connectors (or theca of the coer) a aed at ‘ihr sept rote. Desgrating anmeting ae ocx haste pet “pli ml posing cet spond an improve he aly of daproste meses 365 Finding and using component models Sof, when we hve requ psalms (ag, VolEage), we have lachedineline “Inport Hodelios, Stunt a," estat of a not th Tht allows wtoae Stunt te oan ali ote fl ray path where tte pia nt nfermaon stds, We have neti pth Roca Modelos wl at automata seach the tbe iene of model, ‘ops, ee 0S someting they ae ot fair ih. Here ec ngs con doo make eat an ose he in yO wih "Use the fall mame: You can ase the fll ame (eg Node ica, Cconstanite.pi or Hodelica stunita.Precoure) tele ma ety yo regi withn ode Do ot wom forthe meat whee ‘hese nls aero be acs rn Chater) Define anal: For example we wish 0 acces the 1p coined in dei. Stunt. package, we inlet ie saps Nosed within cur models whch cre the Srunst aa ' Place models in he same directory: One way tomate sre our mod! ‘inte found sto soe the inthe etry ou oe woking If ‘Sou plae lode inte sre etry ten he sl eo ety Inning them. While we an do thie for or snp exam, bore re Teter ways of sorng mek which il e disused ner iC 12 ‘Theis simpli version of the lookup ale. Fors complete wdestandig ftom rch oops done consult Chapter 9 ere langage mein Incladed onthe companion CD-ROM. Flo ar examples we sce tte ter component nee we have sien aren te sme dicey a he modes which we them. In his 2, Siecan ube component model ike ReaSarar or TeaneferFunct ion ‘vou having to pode a quliedMerrchal name (eg, Rodel Sea. Srunite.Preeeure) 37 SUMMARY Component bed approche hie the folloingaantges (6 rRODUCTION To PHYSICAL MODELING WH MODELICA 1. The conte egunton fora component ned oly be wien one, iia he erponet de). 2 Hierareis of components posly many lees dep ca be cet and soc ier re mch aie © ued compre oa "ates ‘presentation where parte, aa and egos oe pee 0 gle mode 5. By using the comnactSzywor, we can ntonatially generate mute suas fora slg conaetr Tn aon, tis nt mer pone a ‘tng th equations by bd 4. Recon ca be poet agit concen which do mt make ene (eg, conning to Sepa quasi ein fo ales with mom ‘ow vibe) sammy these aetheesoos why component asd pyrene evelopment ae rparior equton aed approche fr ge Pobens 38 PROBLEMS Pom.eat 2.1. Us the lca! components dpe i thi bape 1 guider develop analogous components In ter domains. Fr example 2 ‘rmdaional tem ese olla P= has 2.10) any en) to epreset the behavior of pring danger andnias where Prepress force ranted by an semen bi the sprig aie, the damping open and ms he mse Tora gio anclgou dona roe the arial anole wih the connector i ht domain and whch epost domain corepond {oie reson capac and inductor component he eel dma? Rosie 3.2 Deepa model forthe cra howe ix Beam 3.7 ng te block ogo componen nodes from te Eales Section Assn ‘har he inp othe tem the lage a pin Fare! ond the out ‘no nested ins the vege pc. You mht start by wring down {the contin and cnsereton equations and ying formate han ‘auch a wy thr sack equation can be presented by ask he Bock un ond Comecing Components 67 Paone 3.3 Browse th MSL and loka the connactor deft fr lifer domes reer ay common heme? PROBLEM 8.4 Implement nonteor aonlspring wih he lowing cosine eatin Tale) talhe =A en) ear represents torus, represen nga posion and hss “nd epreset coneton” Once implemented ute he pring tha contains component fo the MSL. Ponts 3.5 The power eupe of «restr canbe found by taking the roduc ofthe cen ough he retort vole aera he ree 1 Care a model of restorwhate soe ation of temper Tassos Ram+sr-7) where the mfoence temperature Re the nomial reise ot the Infrnce tempore Ti te tomperare ofthe reso and St tf area) entity ofthe einance with espe t tamper Compa e temperate ofthe rear singe flog eery bees mogh = iv MP— Tons) where mis he mast af he resin yi the specif hat capacity of the ‘ess she comectve heat ransfr coe! and Ta he cen empentire. Ean how hs tor perform in ome of our REC example ‘res ith diferent parame vue, dees the rata gwen of he vio change? Her ae some spi ale By = R(the norma setae) Tang = 600 % = 30 m= 001 @ = k= oa Ss = 00 Chapter 4 ENABLING REUSE, 41 CONCEPTS acing ow al components ily thes pin an fcnt adel developmen process. In ro masini he fle of hese component itis neering to aden how fo make them easable The Model Sd Libya good example oa eusbl cllecton of omgenen Many af he fern Malis prmae ese The ajo are of Models wes special ntodusd opr be ease capbiies| [Fangupss Hk Ada aod. While nt rosary, big faliar h sch Tingnges the ecg ws o poms ruse a ose bps wl ap in unestaning sila ares node ‘These ar several sects to making models esl in Moi, For x sgl, renga tof component mls hat Wor ogee tee ‘STeomnon connector defons in oer orem to shar lafomation ith ‘ach oer, le Chup 3 we showed hat conzector defini or seve ‘fnain avesleay tee deine int MSL By sng the MSL connect ‘tions, me can crete ew modes thea compe wth ibe colee- Mon of exiting ls Reus ilo achive by etenting exiting mses. As we wll how inthis chpty, hs txhige allows common sets of equnions, parameter, ‘Sgeritins, ett e share between model While ths hapter intes fantom nthe Modi guage to promote reve, the wefles fi ind of easabty may aly come cls afer ou tae ened o cee ‘Sov collec of movele Aa ze Bein wid several examples Sedincloe summary ote etre which promote rea in te st eon otis cope 70 _ivrRoDUCHOW TO PHYSICAL MODELING WFTH MODELICA An important aspect of psa sytem modeing eo espcitthe esi ind by wing asl mofling frmutons. In pve sets mls (eater bn block gras are eal tres Decae ech component nel ‘nb ormalae independently witht Inala fh eure asa ‘ay ssumpons sed in ce pss ofthe tem. Th ean nese the ‘ua fr ysis compovea models changes depending the cmt ‘ic he mode ued Whe we dono dca theta in ths cape, Ths aspect of eb ican in pret dein Chapt Oo fis apet oft wonh meting tae ised ‘ytheqaliyefmaeldocunesiaion. Thebeterte dunes the easet (Gere mre ely) wil be fo tbers to eae your mol, 42° EXPLOFTING COMMONALITY Inger ving the sume cade ragmen apes ape ties in ferent lecstons usally leds o rblems. Thirst nln gage such at Cr and FORTRAN as well asin Mola, Ts eanancy nd boats aes ainenance cfteuk. or example i bu found none copy of sack a ove gine ict to wack dow al places whee sue ode have een repeated In Models ch redone ih nde repeated ‘unos. repeated prance or repeated cometr defo, Init section ‘we will dace hw to soa such edn) 42.1 ldentifying commonality Let us evi he mal preset n Saion 33, Loking ot Exages 32°35, em yous: he sndaies ttt hae mol? to ‘ese nls hve may ngs in cnon Ne he el ms sce we evn pos he nd Cet ow oh ‘er anti equine tey be ops be ‘enanes pani. Inter wos ter ghd pence ‘those models. eos 'm ort lp avoid his reption, the Nodelos, BLectrical.~ ‘analog package defines (iis betel Interfaces package) a pact Imoelcaledone?ort. AGnePort component ion whschhar exactly mo erie pins associated ht sn therefore oe cet pth th anole 4. shows te OnePore mode which repress th one et bween the Resitor, capacitor, Inductor and Yoleagesousce ‘adel An imporant hing to ste shut the Gnebort malta I ae With te area pes slong the I of he components of anode. ‘Subtype relosis ae na ned to model Sch lone spy (oc al eins in Movelen(e. comector ein). 484 Creating partial definitions InBsampe 1th modo defntonwasprecededy th part $a yor ‘Taepart int keyword ines whl thirmndel canbe extended, anna te sania. Ih ober Words, he mde a fandaton on which bel ew models tits ot a popet mode sal (aly because ss misng some coninuve etn). The partied keyword, Hke man fetes i ‘Mosel, ot nl enforcer saan toto coment the ites ‘th erin ote develope In ber wands if yousee partial ode 58 wrmoDUCTION 70 PHYSICAL MODELING WITH MODELICA you kn idly tht this ot somthing 08 would ene at ater ‘Smeg tested fom. 48.5 Making elements of a model replaceable 4851 Replaceable sabeomponents Exanpe 4. shoved how we cin dese a coepant to te replaceable. ‘Tere ae two diferencs between 4 normal dolaton and + replaces ‘Once then ate Hen lead, te oupt a be uncon, 1 computed y sly inrpoling betwen the vues yg which cespond ‘trocar da pos 532 Using for loops Ate inereing hing aot is example i hm cots 3 for oop. ‘The exreon dine? i acaly show Band ors complete aay which Incadr cmon [1,---ye-2) Avan gma 0 £0 i ponds the ‘ng of vals the varie should ple at ht varie Wi aa tthe fo hop. The wean tht rented at he tat he {or hops dippers afer the "end or" sttoment esc. Fe this 533 Named arguments nModeica, these wo wat nee functions. Thess to pas he xquents in tore they ae declared inh funtion Seti. This ‘whtwe din sample 52. Letur tthe Puecowsee function slag Slemate way of imbing a enti hs ase, we have provide an exp eqution fr ech pa anumet ‘then ising the fanceson noting fonction hs Wa) eal “Mode so ong aan equation s provided foreach argues. Figste 5.1 Shows the vals ory genemed by his ade en 196 IvrRoDUCTION TO PHYSICAL MODELING WrTH MODELICA ewe. ap serine ene racevtv nt 54 MULTIPLE RETURN VALUES or car nest example we considers fiction whieh at morethan one en vale mapine we nod wo elute a polycnialinand he dete of ‘tat polyoma with spect oe Ciena ara) coming the coeticiens ‘ofthe polynomial Example 5. stows afuecton which ses a ng lop ‘impo he value of he polyol and its deceive. “Once aa ne eo ze) fenton determine ete of he ays being pssd in, Ug this se format, for loop cn te enacted to ‘Salt the polyoma ads dae The flowing ml cas be used tovalde be cleulion ofthe dete: ete teat Fyre een ath cote = (2.6, 3.9, 2.6 sant Bay, moe Weide = mayen simu ‘We ca vt the oy faction ty comping Ean dy. Pencions 97 ‘age Branca pain 55 PASSING RECORDS AS ARGUMENTS or compe finctons, sing in ge mamber of ramets can become cmbersome nese ae, tue den a ecer dpe wich canbe ‘Se gp several ily lato ramen ogee? Unngie we wish {Werente fonction which var th sum see ine wae, YT Asin esse) on re ach wave sits mm ample, gen), fs and phase si Exanpe 35 shows hve weight wre ch fenton, ‘Note tia Exanpe 5S uaude lod record Sefton. Loca definons are mf bate they ele aston with aspelic model or fenton (es. Conguextave). There no hace tht hs Data record could te conned with ance sacar slo named Data tees the dfaon Bese wine Spite fection abd hrf a qaiid mae (Gos complenave at ms be edn ny Goon ofthe Dat ‘record oid the Conpestave faction 55.1 Building record ‘Thefollming oe agmen get sn eabow ibe Compete nton ‘n Bxampe 5 could be ued 98 INTRODUCTION To PHYSICAL MODELING Wir WODELICA Pains 99 ne | BAUSCH ali Se A, i Soe ad Peel ca cnatanee. isd med phat)? ee = opie S Cong ame ert a Seren in, Ee: biaes(e, woiion cont “Ee conte ene tas on Remember bene Datta within function Compleave, erefrencetatrecorddefniton singe ulifed name Comp Lexa. Bata. We ten provide the pecs dis foreach of the aves and ‘ke the inten tn wy, we hve reed the mb of gues | {ConpLevotave oa outa two. The dt proved in thc sl exe ine conplesstavefncton eval te flwing een ¥(e) = 1Ssbe(tae) +22en(Ore +x) +68sin( Ors) (52) gue 5.2 shows the esl of snug he Tat Compete ode 552 Variables within a record ‘Arecorddsesnthivetoteaparanetor stsinthe Test Complete smal some aes, maybe ul ode a record whch cons “ime varying quantities. Te following co rgnt sms ow hc be sccomplied Waker = (2.2, 3.3, Ssnodetécn. thse (846 wneee 2 (22333, 39) Stepan oy hile. comene a, or For this example, we sr sng ese the mame dt at we id in te Testconpleroiave mode cet we ali te ast em odin wih time Mathaba his shoud ead othe evaluon of the following expres: (2) =15tin(éee) + 22sin(6ee +) 4 886° an(léne) (3) 100 myrRoDuCTION To PHYSICAL MODELING WinH MODELICA “The ess of smug the Toa CompLestave2 model ae shown ia Figure 5. Therenlssloincade craton fe folowing two eons Als) = L8sin(irz)+22sn(Ge0 4) +58sin(l4e=) 6) Bia) = 1Bsintins)422sn(6r2 +5) 69 [As we wou eng, th res sow hat he vale of he sna aie {aly fellows te fancton A) te grdinly moves close 0 B(s) = te nbn thet em imiibes DPencions 101 nd teenie, Inagine we hve en exiting erat C subroutine named Cooputecentialpy tht aks presoe snd lemperatie as an inp ond Computes the ety of or working ld san erp Rather th rere Sachse ara Modsizafanet ea, lt Took at how we an al te ‘mal one del from a Mea mel mordertouse axing exes, we mst int writ wapper” ‘unctionln Mode fore wean cali ext sobouine. Example 6 hows hw we would wits wrapper uacton forthe compute.en86)Ey ‘stron er Sidon i Tecate. 56 _ USING EXTERNAL SUBROUTINES ‘We bine denntd How a vary of fncton xa be implemented in Mods, While it reso wre Models funn, sometimes one ‘eno alla abn writen nC oe FORTRANTT In hs ection me wll Show sn cumple a aw hs dove 56.1 External subroutines ‘A common requirement fr thrmafyeanic adel is compute prop- nis (eg ebay) fa ering Mud (eg, water fora gen peste (ono. evehater (98.81 i] ‘eanpt BA Mn wp fsn rs Crti “Toe uote computeenthalpy wet in Example 3.6 shoud hae Cefn pope tos someting ie “Ted fo the Cfncton pooper a deine willbe covered shay in Secon S78 562 Language specification nay i ot te oni ropenty we Wout nd, In fic, my simile properties ae fen ete Papers of wring is a oi ‘Salted war ae calle stan able” Example 87 shows how we old ‘rte function hich cll an sxearaslswouoe tat wets seve opti at onc. nhs example, we hee assumed he saci sri EFORTRANTY. * The FORTRAN? cae fore ea2eprops sabre ‘om Example 7 wood be similar Dideernncat etree gsm pipe lo SRST ATSC ROMTENTE ae ede ve [Bowpe 7A Node wee bo rs FORTRANT mane 5.63 Invoking external subroutines xtra sorties eink just ke any the Modelicafunct4on In deri vate he facto, he sino ol ets ase the tie, Typely. oly mpd verson of th sbrotne weld be reed td mote source cde How the stot is acesed (comple & linked saa pecs mot covers by the langue spesicatn, 57 LANGUAGE FUNDAMENTALS S71 Arguments ‘Ac we have sen inh hap the angen fnton ae defines by the inp compooen ne publ section of he fet. eiton. Ay ‘mponen! preceded bye inp quale pees quay eg pss intothe unetion. Likewise, any empoen preceded by the output quale repens a qty being erm byte fonction All emponetn he ‘public secon mtb ced input output, ‘At we win Ezample 35, when the numberof argument sas sting loge ts seat pus tomaton is unctonses record. Thredacet the munber of agen (and conus shel wen eri) 83 2 Local variables “Any gusies wich ae cacalated tom the Saput vals, bt ae nt ‘utp vale, cle Tol tables, Ar we sm ip Example 3, ‘eh arable mut be decared nthe protected section ofthe fonctScn einton singe keepin athe ass of exe ocala ‘se nu sored between function ioc Inter Wor, you Sign ‘rl toa varie dre one meetin of the unceson, ou canna expe ‘ost have tha ale she pest even, cto 108 573 Algorithmic semantics ‘The main prose ofa funct soni to perform algeitnie clans ‘Tra cleiaon nine looping and conor semen el apr win slgorsetm section The mow ipo hig wo remeber hou an agorsthm econ tht ini ponile o mien the ae varie pees. I ech ease, te tw signet wil ple the ae fom any previews igen To ‘ndstan he sgicance os conser the lowing code age Incase, col he st esigamen = import. Thi in comes lemeguattonteson ver nus equliyacntpeesen npc ‘spats, Bot of hes equations re signet nl ed othe imple z= y = 2 “There artwo wa ol he dierene between asgnment anion st signe moles the += operon we equine he = epratoe ‘Second, a sige mst appar Wibia an algorttan Seton ood | ‘ston mst pee Wiha an uation section. This els ea a ‘fin abou weer een ia agent ran equi scents all meas al fncton ie Models behaves slmst xa he suteoue in or FORTRANTY whee vals can be ‘signed and essigned vals. S74 Branching ample 51 and ST conan i semen An een cen lio lncade tree cle ts wel esse eed cance. Fi xa 104 AvTRoDUCTION To puYsiCAL MODELING Win WoDELICA 875 Looping algorithms oping is ido inplemen algae tt regi sadn (the y sauder vale tot ty he Poyval fenton in Example Sa). There {teow Kinde of lope, A whe nop iso whte operations ae performed Tepetly hie me coon raise. Cone awh oop it [recdedby sone azn oatnents.The#incame model in Example [Taos how awh oop canbe wed. Abie seres the zoel forme 7 so eoeening Aft ay inalntion siemens he statements ide te hie loop ae ‘alstedepesely whieh oneanexpeson ome Condition esis "Te for teen in Moen x comenin for oopng over he contents veces aslo the "rec construct i anuage sch Pe nd Tel Te general ofthe for stant Tienes inno “Bae te sateen is op i soma eaescay st ech ae cna! wit e Yeo Tomevectos Asap poate ite poie log oer ‘cre, on nr rae). Tn Bnple 33, epson 2m est eter fl integers tetween nn in sae 5 ti ewes 9-21 eats 2 ‘cor sring wigan ouing dow oy tra of. Tid ‘recor shri eco nn Sena 632 5116 Invoking function I 4 tance Son ivked by providing each argument inte form of ae ‘epition os we tm in Toe Paecenon) the ponents appear in any Shier If a suton eve fr oe aramet te a extaton must Be freefall aunts On tetera the nctin invocation Ses ot Fncage eunon forthe rumen bt simply a coleson of mls then ie trier fhe components inthe Function dion determi he equied rer fb argument von, Pevcions 105 Now lt ws examine how oe the tin ae ofthe fonction. If «func fon has a single etn vale (Le sug output variable i is “enon on Example 5.) he tay be we in expen eh ‘phere ves a in Example 3. te {faectdoninveraton col bese nan estonia dit st fer the complete ight and ie. Pheer, he elt han side hold be oma seared it of vrs cclned in paenbses. The owing i legal esampl of inckinga¢ance Son wih mull etre aves (On he ern, hs sot lel ict: bec only vcals (em expresions) may pps the lef hand side 37.7 Built-in funetions Mode roids acalacton of itn ants. Ins seton, me will, Soc on OF te bitin ctons sa he eine i Be sce ik ‘Caper tec thy ole aay option ITA Analyt ype ‘The analyaeype() fino red to give the model a cance 0 somite is boar to ier types of ales, Te snayei=TP= 0 fet ting ona the ype analyse corey being pore. Te rile eum vale my nla, bat re ot Ed 1, he ees sown ‘ies ‘aysanich Beata east SRE! mages seen SESS Uta etn gay ae, ‘Rie. meat ‘Sapam TTA dein esse 106. mrrRopucriow To punsicAL MODELING Wr MoDELICA 57272 Abwste rae ‘The abe) fenton kes sing argument, nd comptes the abeoate alu of The amen type can beciterReal oe ntoger sre ern ‘ypeis the same ath goment ps, Matalin S dened oe) {EE ESS ry een S773 Sign ‘The eign) fntion kes asnge argent, x, and es an incon whether negate oe pose. Thetpealscanbeciber Renter integer atthe eum alvaysan Tateger. The eight) fenctin dined als eco ° 6 1:30 sont) S774 Square vot ‘The aqet () function tks singe agumen. x snd reams he sue soot of The ype ofr canbe ih Real oe Lue bt thee tle ‘hogze() Sewage a Rani. Toe ale of mst be peter ian ore (> S778 —Celngand too function ‘The col () function ke asnle eget, and rum he sales imeper notes than 2. Likewise, he for () fac tks «single ag ‘tet 2 anders he ret integer eter than a porn is {oretze abou thee ents tat wl be etn ale en grin ht ‘theta sens, ts tan Tneeger ine Medel see sed, he {sgument and eta ypeforboh cei () and Elcor () isReal, Examples wing tee fncton nce: eil32) + 40 sicag) 3 to oo fot-32) 3 “40 5776 Troneation The Snteger') faction jt ie the £100%) faction kes asap spunea retars the ester not rete ton 2 The ecce Pacers 107 is thr wile Flooe() res a Read, integer) reums an zntger Examples of wing te sneer () fenton cae: letgee(8.2) > 3 6 Ineger-22) 3 4 S727 Divison ‘Thea () faction esto arguments andy, anders algebraic quiet of 2/y wth ay factional prt scared Le texon wa 2) ‘Theargumeats may be of ype Real et Integer eer of fe agen anette renlisaReslahereie he natin Inceger. Euampls fusing he A) fonction ice ava) 420 aw-33.12) 5-20 (33-12) 5 “20 aiv(-33,-12) 320 (7,2) a a9 aivict2) 3-3 avi.-2) 3 re S798 Remainder ‘The ron) fnesonakstwo aguneats, any. andres theremin lacardd ty he dv) funtion The canbe egred mathemati a rem(ayy) = 2 — dite) +9 ay “Te arguments may be of ype Real ce Entages ite of the agent isaReal thereat Roa herve he eslisan Tntogey. Examples wing he com) ition ne rem(22.12) +08 rom(-32.12) 5-08 rom(s,-12) 5 08 rem-22,-12) 4-08 oan) 5779 Module ‘The mod) futon tks two arse, ad yan retake od of sandy, smodtesy) =~ loose) ey 619) ‘Theargument may bof type Real or eeges Melero he spent ‘tanec the reukisaRe abervie he nits Incoger. Beales 108 mv7RopUCTIONTo PisICAL MODELING WITH MODELICA of ing the no) feo ne sod(3.2,12) + os 24 uw “a 578 External subroutines ‘As scussedin ection 5.6 fen deine tae existing sobrotines writen in Cor FORTRANTT. Let wee te desis tt werent cone ytheexample S781 Typematching "Tile 5.2 shows he Modecn bit inpesand tle conesponting Cpe “Tis why he anton prtype for Braple 6 as | Example 5:7 wee writen in, ction prot woul be Pactons 108 feeser bit) ‘ould carp othe following C sete definition: secu toca ( ‘dame a) f Ne that Modi des not apport the sng fers contig vase Sie ays If san sue, ner to pss he rc a i an to the C language, the ModecaInguae pein ao roids forthe posit that he extemal rtroutne ite In FOR [FRAN Tate £3 shows th ping between Mon bik pes a FORTRANT? types! Ths mapping ma bd to crete he sobre header Shown a Seton 58.2 When ooking 2Clngage abot, it posible pst ecard the extern tte, Whe using ocd inporan wo kep sve tng in mind. ns when 2 Modeca record is ped ind language ‘hbtetine appends rsapeiertoasice These {ston shld cade he same component Mele ecerine ‘Sine rsd ung th type mapping sbown in Table 32. So he olin recordin S782 Custom mbroatine nection 1m or examples, we hive seen on way tht extra subroutines can be lnvoked In all ewes be Inngage an the eer of agueats wa specie ‘iy. es recommended ha extemal subroutines be ved inthis Way ‘stencer possible ved ay potatlconfsion ower in some cemsages my be neces o cso the an ing oo vale. Tis eae comes tout pmsl) when Csrowioe 10. pvmopucrOW 70 pHnsICAL MODELING WITH MODELICA sendy ests that retusa (be C sense) her tan assigning 0 ‘arable which ma pase by reference. For example, tus inwgie a the compute-cnthalpy subrine dacased in Seton 56 and eed a tample 5.6 ada pte which eked ke ‘he eta ae fhe bone wa the etal. Tow ti sbrotine recy, we could soa the external declrtin n Example 6 wih the fellowing desta S783 Compile options ‘Simply saying the exter subroutine ste wits inC ot FORTRANT? oes ays provide enough fort, For example, FORTRANT? and ‘Coomplessometines spend or pepend a” chatr' srotne nanes| inte comple obj ade I ihe respon a he salto ol ove yo ea thc adoring tem pees S784 Sideutets anions shal mothe side gets hey st anys etn he sae put fora gien sof pt). The i pricy porate i ming ‘hn wring extemal ubetine eae sexy 10 aes tds Such ef These ie efees may come fom eadig fo of wing tl vals orm tae of hr panty tari wtih tems ae “he way tai effets i to ke ett fncti's opts ae \ependet oly cae pat. Ir wor, 20 ea om ori ony risen da (eg. lol Yabls oi), In sme ete pratt to avd lacing perso data tt el pose wo wed se tect, For example it ssf, when opiizng te performance of an extra strut, tedice sme Kindo eset cache Sach aproase are fine 20 longa hy conti to st the estton ha fo given st of inp values, the our aes ae sayeth sae Le, te each ingen evfrmanc ut dees ot fet he rea) 58 PROBLEMS PROBLEM 5.1 Write intone perform enc inepolation x adi ‘othe arganet wed forthe PLecew ae sin fom Example 3 eddan ional amen tha provides he slope of he ation (ea each {rid po. Assn he ole of x i defined uch that =p 2 Sy he -a( (16 i 1 ain ri () eum dem 19 we) = aff bP toe +d (5:20) where ihe ae fhe incon ae pid pont ond (18) te slope fe fst tthe rd poi PaoBLen 6.2 Read Seton 145 and then cet « Malton tar computes the Ici for te inepoainfrton Probl 31. Toke ‘hing pe, eoune De gr yard and gr vas are ‘leona (Hin Yu ely only eed diferente Equation (520 bat remember tht €(2), PRonuu 6.3 Write oftion tht ako vector (Le an army of el ruber} cx argent nd ers the maids he econ PROBLEM 6. Write aft 1 take he mer pat of ro wets. Be ‘ae io inde assertion tha ns the vcr ore he sme se PRoRLEn 6.5 Write afncton ht kes the postion and maser of fe Bods and cleats he grvitina fore betwee thom. The groin force shoud be rend a vet The age of he roitona force Us gen the equation: (2 (s22) (523)

You might also like