MSU LIBRARIES “ RETURNING MATERIALS: Place in book drop to remove this checkout from your record. FINES wiII be charged if book is returned after the date stamped beIow. IMPLEMENTING A FUNCTION LIBRARY FOR NONLINEAR DYNAMIC SYSTEMS BY Tsun-Yu Chou A THESIS Submitted to Michigan State University in partial fulfillment of the requirements for the degree of MASTER OF SCIENCE Department of Mechanical Engineering 1983 IJI'V" ABSTRACT IMPLEMENTING A FUNCTION LIBRARY FOR NONLINEAR DYNAMIC SYSTEMS BY Tsun-Yu Chou ENPORT-S is a bond-graph based interactive simulation program with extensive graphic ability that allows the user to control and analyze the simulation of physical systems effectively. To extend this ability to the nonlinear domain an immediate need is an explicit expression of the nonlinear constitutive equations that can be defined by the user and modified easily and efficiently. An interactive program, NOLMOD, has been written which is based on the core concept of a prestored function library. Certain efficiencies are available by using a pre-programmed library; flexibility must be achieved by other special methods. Chapter TABLE OF CONTENTS LIST OF TABLES o o o o o o o o o o o o 'o o o o o o Io LI ST OF FIGURES O O O O O O O O O O O O O O O O O O O I NTRODUCT I ON I O O O O O O I O O O O O O O O O EQUATION FORMULATION FOR NONLINEAR BOND GRAPHS 2.1 2.2 2.3 2.4 2.5 Bond graph structure . . . . . . . . . . Key variables and causal considerations System equations and state equations . . Example of matrix formulation . . . . . Computing implications . . . . . . . . . EXAMPLES O O O O O O O I O O O O O O O O O O O 3.1 3.2 3.3 Spring-mass-damper model . . . . . . . . Hydraulic system . . . . . . . . . . .g. Dry friction O O O O O O O O O O O O O O DES I GN OF PROGRAM NOLMOD O C O O O O C I O O O 4.1 4.2 4.3 4.4 4.5 Basic considerations . . . . . . . . . . Classification of equations . . . . . . Function library . . . . . . . . . . . . Evaluation of functions. . . . . . . . . Structure of NOLMOD . . . . . . . . . . ii Page iv (DONUIU'IH 12 17 18 18 23 25 28 28 29 31 33 34 Chapter . Page 5. CONCLUSION . . . . . . . . . . . . . . . . . . . 39 5.1 Conclusion . . . . . . . . . . . . . . . . 39 5.2 Limitations and future work . . . . . . . 40 LIST OF REFERENCES . . . . . . . . . . . . . . . . . . 42 APPENDICES A. HOW TO USE NOLMOD . . . . . . . . . . . . . . . Al B. IMPLEMENTATION OF A NEW FUNCTION . . . . . . . Bl C O S OURC E CODE FOR NOLMOD O O O O O O O O O O O O O C 1 iii LIST OF TABLES Table Page 1. List of library functions . . . . . . . . . . . . 32 2. List of functions in alphabetic order . . . . . . A13 iv Figure 2.1 2.2 2.3 2.4 LIST OF FIGURES Basic fields of a multiport system . . . Identification of key vectors in a mixed causality system . . . . . . . . . . . . A multiport system having only integral causality O O O O I O O O O O O O O O O (a) Spring-mass-damper model (b) Bond graph model . . . . . . . . . . Augmented bond graph . . . . . . . . . . Subroutine FCT . . . . . . . . . . . . . Displacement diagram . . . . . . . . . . Velocity diagram . . . . . . . . . . . . Hydraulic system . . . . . . . . . . . . Bond graph of hydraulic system . . . . . (a) Bond graph of bent hose (b) Modified bond graph of hose . . . . Dynamic model of a vehicle . . . . . . . (a) Bond graph of vehicle model (b) Saturation function . . . . . . . . (a) Modified bond graph of vehicle (b) Inverse of saturation. . . . . . . . Page 11 13 13 20 21 22 24 24 24 26 26 26 Figure Page 4.1 Basic components of NOLMOD . . . . . . . . . . . 35 4.2 Subroutines calling structure for NOLMOD . . . . 36 4.3 Data flow for function library . . . . . . . . . 38 A.l Function A352 . . . . . . . . . . . . . . . . . All A.2 Function ABSQRT . . . . . . . . . . . . . . . . All A.3 Function RCPSQR . . . . . . . . . . . . . . . . All A.4 Function COULOM . . . . . . . . . . . . . . . . A12 A.5 Function BRKPT . . . . . . . . . . . . . . . . . A12 A.6 Function SATUR . . . . . . . . . . . . . . . . . A12 A.7 Function ADJSAT . . . . . . . . . . . . . . . . A12 A.8 Function PWLIN . . . . . . . . . . . . . . . . . A12 A09 Function INTPLO O O O O O C O O O O O O O O O 0 A12 vi CHAPTER 1 INTRODUCTION During the past decade the digital computer has come to play a very important role in system simulation. Many general purpose as well as special purpose modeling and simulation programs have been developed. One general requirement of such a program is that the user need not have extensive knowledge of computer programming and numerical techniques. The typical user can learn to operate such a program, if it is well-designed, within a very short period of time. Many important engineering and physical systems are described by differential equations. Simulation programs provide a way of solving such differential equations and also provide graphical and tabular output that makes it very easy for the user to study the behavior of the systems. Selected parameters and functions can be entered to provide necessary information about the differential equations. They are constructed to define the relationships between dependent and independent variables and among dependent variables. How to provide such information to a computer is a topic in which we are interested. Therefore several simulation programs are studied, including CSMP, SUPER-SCEPTRE and DIFFEQ. CSMP is a general purpose block-diagram-oriented program developed by IBM for simulation of physical and engineering systems '[1-3]. SUPER-SCEPTRE is a special purpose program intended primarily for electrical systems[4]. DIFFEQ is a general equation-based program developed at Michigan State University for solving ordinary differential equations [5]. Patterns for entering data are very similar in both CSMP and SUPER-SCEPTRE. Control statements and data statements are used as input data. Control statements tell the system what kind of data is provided and how to handle it. Data statements give the value of parameters, the types of functions and other related information. Some commonly used functions are pre-programmed, and both programs also provide function-generating routines for special functions. Then the system, based on the data given, prepares the necessary subroutines for calculations. The user can also write his own subroutine, if he is familiar with computer programming. Then the program will compile and load the binary file and set up the run-time program. This is the approach taken in DIFFEQ. A FORTRAN subroutine is written describing the differential equations and the system provides the calculation and display capabilities. The common point of all three programs is that they have to compile the function subroutines and combine them with the rest of the program. There are several disadvanteges of such a process. First of all, it take both time and disk space to do it. When a lot of users are active at one time and every user stores a binary file of the program on the disk, that can use up a lot of space. And the compiling and loading process takes computer time. An advantage, however, is that the run-time program can be saved for re-run with new data and execution control statements. Subsequent simulation jobs using the same model may avoid repeating the translating, compiling and linking process. Some careful planning is necessary, coupled with a sound background in FORTRAN, to ensure that the saved model has sufficient capacity for later uses. Since both CSMP and SUPER*SCEPTRE are used in batch mode, user has to submit the job all over again when the data are changed. But DIFFEQ is a fully interactive program in which changing of parameters can be done on-line. This feature enables the user to have direct interaction with the simulation. This is a great advantage in design, since it can be re-run relatively quickly until the user is satisfied with the results. But changing of a function type in DIFFEQ must be done by modifying the subroutine. Then the compiling process must be repeated. ENPORT is an interactive program based on bond graph theory for modeling and simulation of physical systems which has many of the desirable properties mentioned above [6-7]. However, at this time the ENPORT program can only handle linear or linearized models. Demand that ENPORT be able to handle nonlinear models is increasing. The purpose of this work is to develop a program that extends ENPORT into the nonlinear domain. For nonlinear problems functions are specified, instead of just constant parameters. Therefore our strategy is to set up a function library for such a purpose. The program NOLMOD was written to achieve this goal. The user can choose desired functions from the library and can modify these choices without leaving the program. To use this system the designer first runs ENPORT to read the bond graph as original data and to assign the causality. Then NOLMOD takes over the rest of the work. The program NOLMOD has been installed on the PRIME-750 computer of A. H. Case Center, College of Engineering, Michigan State University. CHAPTER 2 EQUATION FORMULATION FOR NONLINEAR BOND GRAPHS 2.1 Bond Graph structure One of the most important features of the. bond graph method is the concept of fields and junction structures. These terms were defined by H. Paynter [8]. A multiport system is partitioned into a set of distinct, interconnected fields, namely, a source field, a storage field, a dissipation field, and a junction structure. By definition a junction structure is a collection of junction elements : 0- and 1- junctions, and transformers (TF) and gyrators (GY). In a standard bond graph every bond is connected to a junction element at least at one end. It is useful to classify the graph bonds into external bonds and internal bonds. A bond connected between a field element (C, I, R, SE, SF) and a junction element (0, 1, TF, GY) is called an external bond. An internal bond is a bond connected between two elements of the junction set. Furthermore, external bonds are classified into three groups according to the nature of the elements they adjoin : source field bonds (SE and SF), storage field bonds (C and I) and dissipation field bonds (R). The equation structure implied by a bond graph is constructed based on these classifications. Figure 2.1 shows the bond graph field structure [6]. 2.2 Key variables and causal considerations Figure 2.2 shows the key variables (vectors) used for representing the input and output variables for each field. U is the input to the junction structure from the source field, V is the output from the junction structure to the source field; these are associated with the source field bonds. 2 is the co-energy variable vector, X dot is the time derivative of the energy variables vector; these are associated with the storage field bonds. Do is the output from the dissipation field to the junction structure, Di is the input to the dissipation field from the junction structure; these are associated with the dissipation field bonds. Subscripts i and d stand for integral and derivative ports of the storage field, respectively. Causal consideration is a very important aspect in the bond graph method. It provides all the information concerning input and output variables. Some multiports are strongly constrained to certain causality (SE and SF). For C- and I-fields, the constitutive laws are quite different for different causalities. Usually integral causalities are sought. Derivative causality arises for systems in which Storage field C Source field I (1, O, TF, GY‘ ° SE SF ...... Dissipation field Junction R Structure Figure 2.1 Basic fields of a multiport system. Source field (SE, SF) 1 U V ‘ i i Junction d (0.1) Structure (C,I) . Z 1+(1. 0. TF, GY) ‘1 Integral D I D Derivative storage i‘ 0 storage Dissipation field (R) Figure 2.2 Identification of key vectors in a mixed causality system. some storage elements are not dynamically independent. The energy variable of the derivative storage element port will be expressed algebraically in terms of other independent energy variables. Therefore any storage element ports with derivative causality do not contribute to the state variable set. For a nonlinear system it may be difficult to express one energy variable in terms of the others explicitly, since they might be coupled by nonlinear algebraic equations. This situation is typical of nonlinear mechanics, for example. The causality for the R-field usually is determined by the source and storage-field elements. Usually they are relatively indifferent to causality. However, in the nonlinear case some constitutive laws for the R-field are not uniquely determined for certain causalities. An example will be shown in Chapter 3. 2.3 System equations and state equations First we shall look at the situation for linear systems, useful as a guide to our thinking in the nonlinear case. The field equations for linear systems are as follows: Source field : U s U(t) (2.1) Storage field : Z=FX+FX (2.2a) i ii 1 id 6 and Z = F X + F X (2.2b) d di 1 dd d Dissipation field : o . L D (2.3) o i Junction structure equations : x = s z + s x + s D + s u (2.4a) i 11 i 12 d 13 o 14 z = s z + s i + s D + s U (2.4b) d 21 i 22 d 23 o 24 D = s z + s x + s D + s U (2.4c) 1 31 1 32 d 33 o 34 v = s z. + s x + s D + s U (2.4a) The system equations above can be reduced to a single matrix state-space equation by some suitable manipulations. (We assume the required inverses exist.) Thus we arrive at x. = A x. + B U + E U (2.5) l 1 The E matrix only appear when we have mixed causality. One may expect that all entries in matrices A, B and E are _real numbers which are derived from the parameters of the physical elements. Matrices A, B and E can be calculated from a causal bond graph after parameters are given. With 10 given X and U, X dot can be obtained easily. And by use of the equations (2.1), (2.2), ~(2.3) and (2.4), all system variables can be found. For some nonlinear systems equations (2.2) and (2.3) are no longer valid. They will be in following form: For the storage fields: 2 = (X ,X ) (2.6a) i ¢Fi i d z = 4’ (x ,x) (2.6b) d Fd i d For the dissipation field: D =(x.,u) (2.8) 1 1 may not be obtainable. System equations may be firmly coupled together. It may be very complex to reduce the' system equations to a single state-space equation in the form of equation (2.8). Typical stumbling blocks are equations (2.6) and (2.7). Therefore in this work we restrict the range of consideration to the case of: (l) integral causality (hence xg=0) (2) (3) See 11 no implicit R-fields (hence S =0) 33 constant moduli for TF and CY (hence S have constant 13 elements) Figure 2.3 for the key vectors in this case. Then the Source field (SE, SF ) I Storage U V Dissipation field , , field (C I X Junction Di (R) ' Structure Z DO ‘ (1, O, TF, GY ~ Figure 2.3 A multiport system having only integral causality. field equations and junction structure equations will be simplified as follows: 2 = 4: (x) (2.9) F D a ct (D ) (2.7) o L i i = s z + s D + s U (2.10a) 11 13 o 14 D = s z + s U (2.10b) 12 Rearrange the equations in the following sequence: U = U(t) (2.1) z = 4>(x) (2.9) F D = s z + s U (2.10b) i 31 34 D = (D ) (2.7) o #L i i = s z + s D + s U (2.10a) 11 13 o 14 With U and X given, then 2, Di, Do and X dot can be calculated step by step according to the above sequence [11]. Viewed as a total procedure this is equivalent to the explicit form given by equation (2.8). 2.4 Example of matrix formulation An example is shown in this section to demonstrate the reduction procedures for both linear and nonlinear models. Figure 2.4 is a simple example of a spring-mass-damper model. An augmented bond graph is shown in Figure 2.5 which displays the fields and junction structure. The field equations for linear system are as follows: Source field : U = U(t) (2.1) Figure 2.4a 13 Figure 2.4b Figure 2.4 (a) Spring-mass-damper model (b) Bond graph model. I u i Se : Source field i ___________ J F"'1 l I 2 1 : C I I f ----------- 1 I I I i i i J! { Junction E E E 1 E Structure 5 M) i I u L___J 3 4 Storage { ----- 3----1 field I R u Dissipation 2 : field h- --------- 4 Figure 2.5 Augmented bond graph model. 14 Storage field : z = F x F k 0 q 2 __ 2 v o l/m p 3 3 Dissipation field : [2% PM] Junction structure equations : 3 Is 5 == ll 13 D S S i _ 31 33 q I0 1 g o g 2 I l | I P = '1 0 :"1 : 3 ........ J----J -.--_ . . V 0 l : 0 : . 41 The system equations can be equation: reduced to a (2.11a) (2.11b) (2.12a) (2.12b) (2.13a) (2.13b) state-space 15 x. = A x + B U (2.14) Where : -1 A = (:5 + s L ( I - s L) s ‘]F (2.15a) 11 13 33 31 -1 B = [s + s L ( I - s L) s ] F (2.15b) 14 13 33 34 Therefore, by matrix operations on equations 2.11a, 2.12b and l.3b, [ 0 l/m A = (5.16a) -k -b/m 0 B = [ J (5.16b) 1 If the storage and dissipation elements are nonlinear, then an explicit form of state-space equation (2.14) may not be obtainable. We must follow the procedures described in section 2.3 to obtain the implicit state-space equation. The field equations will be as follows: Source field : U = U(t) (2.1) Storage field : z = d}(x) ‘ (2.9) 16 F = (q ) (2.17a) 2 4E 2 V = (P ) (2.17b) 3 43 3 Junction structure equations : D = S 2 + S U (2.10b) i 31 34 ' D = [o 1 ] .F ‘ + [o ] U (2.18) Dissipation field : D = 4>(D ) (2.7) o L i F = (v ) (2.19) 44:. Implicit state-space equation : x = s z + s D + s U (2.10a) 11 13 o 14 [.4 I 0 1‘ PF 7 r o. [F ] i 0 [U] 2 2 4 = + + (2.20) e -1 o v -1j _ 1} 3] ' 1 ~ 3‘ ' Values of F2, V3 and F4 should be obtained from equations (2.17), (2.18) and (2.19). _ 17 2.5 Computing implications We now turn our attention to the practical question of how to implement equations (2.7) and (2.9) and the procedure for solving them. For equation (2.7) and (2.9), the nonlinear functions describe the relations between input and output variables on a port-by-port basis. In order for the engineer to supply such information to the program interactively, functions may be pre-programmed and parameter-type data given during interactive running. The most common engineering models involve one-port elements, in which case only one dependent variable is involved. For multi-port field elements the output set is a function of the input set of two or more variables. It is more difficult to define a set of library functions that can be used for describing a variety of multi-port elements. Therefore we restrict the bond graph to contain one-port field elements only. This will simplify the problem again. A function library that contains commonly used functions and a function-generating routine are used to serve the purpose. The library can also be used to describe nonlinear transformer and gyrator element moduli, although they are not implemented at this stage of the work. CHAPTER 3 EXAMPLES 3.1 Spring-mass-damper model For better understanding of the procedures for simulating nonlinear systems by the bond graph method and NOLMOD program, the example of a spring-mass-damper system in Section 2.5 is used for demonstration. Commands and data 'listed below are given to ENPORT. GRAPH SE 1 , C 2 , I 3 , R 4 , 1 1 2 3 4 . CAUSAL After causality has been assigned, NOLMOD will classify the basic equations according to types of elements and causal conditions. INTEGRAL STORAGE ELEMENTS 82=FCN2(Q2) F3=FCN3(P3) DISSIPATION ELEMENTS 18 19 E 4 = FCN 4 (F 4) SOURCE ELEMENTS E 1 = FCN ( TIME ) Then the user can define the functions for the storage and dissipation constitutive equations. The user-defined functions are as follow : FUNCTION 2 : E 2 = 0.0000E-01 + 4.0000E+00 * Q 2 FUNCTION 3 : P 3 = 0.0000E-01 + 6.0000E-01 * F 3 FUNCTION 4 : E 4 = 8.0000E-01 * s:ou( F 4 ) * SQRT( ABS( F 4 ) ) Following the causal conditions in Figure 4.5 the state equations will be : o = F (3.1) P = E r E - E (3.2) 3 1 2 4 Then we can integrate equations (3.1) and (3.2) to obtain the displacement and momentum of the system. Now we may use DIFFEQ to simulate the system for demonstration. Figure 3.l is the subroutine FCT used in DIFFEQ [4] and Figure 3.2 and 3.3 are time responses of the displacement and momentum. 20 .90h mcfipzomnsm H.m mhswwm atu tcahu- 0 cm I mu I «u o .m.>¢ua nu o .«.>¢ua u mzouhcaou wocnmIUhCPmIIIw .nu.mo¢ a nu u a - vu u . onrcnow adunu zanhcmnmmnaIuow Amv> a At\.«. a nu an.) n v a mu 0 . mzouk¢aow agunu uo¢¢ormnuuw m.a u c a «u o . onhcaou oamnu uocaomIIIw Anvcaon Amvcuu: Anvca-x o baazn «hcounuo uuuuuuunuuununnuuuuunuuunuunuuuuunuuao kzmnonuuuoo zonku~au - Ianu mmc: - : IIIo hrcrmzoo uzuaam - x IIIW mumou zo~ku~au . 'u IIIo sztuoaummua mmcc . nu IIIo women oznunm . mm .100 mmct uo hxonw: - aw IIIW 0.0 camv> u 0.“ can.) . mzouhnozoo gauhuznuncw rakzmto: mac: n nmv> IIIu zomhuuuumo etuunm a an.) 14-0 -uuuunuuuuunuuunuuuuuuuuunnuu-uuuuuuo caxsourou\10ttoo t.x Acwc Aomvcn new“) Remv>¢uu vuatuu .>¢ua.>.x.kou uzuraocnam 21 am mm .Emnmmflu EDPCmEoz m.m mhzmwm mz_k sm m_ a“ _ CJ*“UDCL_J<(LJUU:ELUZZF— 22 am mm .Emmwmflv HCmEmomHQmHQ m.m omsmwm wzah sm ma 5H EECDIEUUZZF—IDIE 23 3.2 Hydraulic system Figure 3.1 shows a simple hydraulic system. A hydraulic motor is driven by a pump. The 2-block 4-way valve is in on position, a pressure relief valve is used to maintain system pressure and an adjustable throttle is used. to control the flow through the hydraulic motor. The corresponding bond graph for such a hydraulic system is shown in Figure 3.2. Causality is uniquely assigned according to basic rules. In modeling the pipe line, attention is focused on the bent hose, since the pressure drop is significant at the bent compared to a straight line. Figure 3.3a shows a portion of bond graph for the bent hose which includes inertia, compliance and dissipation. Pressure drop in a bent tube is expressed by : Q 2 P = K J?- (---) (3.3) Figure 3.3a shows the causality of the dissipation element Rh which indicates flow rate Q is input and pressure P is output. Equation 3.1 matches the causal condition of the R element, namely, pressure P (left-hand side) is given explicitly by flow rate Q (right-hand side). If the inertia of the fluid is considered to be insignificant in the system, one might like to exclude the 24 Figure 3.4 Hydraulic system. Rp Rpf Rh Ch Rm CS R1 1 I I I, I I I I I st_.1I—-TFI—~o-=IlI->o—-I0—->I1-=ITF—-ll)—>o—~I 1I—>Se I L l l Ip Ih Im Il pump hose relief motor shaft load valve Figure 3.5 Bond graph of hydraulic system. Rh Ch I. l Rh Ch '—=fl 1)-" 0'-=d 'r ‘I i —»I 1I—-=-0——>( I h Figure 3.6a Figure 3.6b Figure 3.6 (a) Bond graph of bent hose (b) Modified bond graph of hose. 25 inertia from the model. Figure 3.3b shows the modified bond graph after the I element is removed. The causal condition of the Rh element is changed, while the rest of the system remains the same. Therefore the input and output relation is changed. Equation 3.1 can be inverted easily to fulfill the causal condition. For the user's convenience it is a good practice to have the simulation program invert the function when requested. The user can ask the program to invert the input-output relation of the function, if required, while supplying the same function as before. However, for some cases the inverse of a function might not exist. Therefore an alternative can be very helpful. An example of this situation is presented in the next section. 3.3 Dry friction A vehicle can be described by a simple model consisting of masses, springs and a damper as shown in Figure 3.4. Here M is the mass of the vehicle and m is the mass of the tire. The spring function k models the tire. A bond graph model of such a system is expressed in Figure 3.5a, in which causalities are also assigned. Now if we assume the damper is not well lubricated, such that it experiences dry friction when the car is running. The relation between force and velocity for dry friction can be approximately expressed by the saturation function (Figure 3.5b). When the velocity reaches a certain value the friction force will Figure 3.7 Dynamic model of a vehicle. Se-——(1-——(I I /R OF-wv1A\\- l C F) Se-filfill F, ...... T 4v 01—..0 I S f Figure 3.8a Figure 3.8b Figure 3.8 (a) Bond graph of vehicle model (b) Saturation function. Se J. VI) 1-—=HI CHI-fil/R A IF I \c Sf Figure 3.9a Figure 3.96 Figure 3.9 (a) Modified bond graph of vehicle (b) Inverse of saturation. 27 remain constant (Fs). According to the causality of the R element, velocity is the input to the dissipation element and force is output. The saturation function is suitable for defining the relation between force and velocity. Often the mass of the tire can be neglected compared to the large mass of the vehicle. A modified bond graph model is shown in Figure 3.6a. The causal condition for the R element has changed. However, the inverse of the saturation function has an undefined region for F, which is now the input variable (Figure 3.6b). From the standpoint of computation serious difficulties might arise in such a system. Therefore an alternative might be necessary. One way of doing that is to define a very large finite value for the slope (instead of infinity). The examples above show that causal conditions can change when the physical model of the system is modified. Nevertheless, we desire that the simulation program has the ability to handle it. It should not only provide a variety of functions but also be flexible in their causal implementation. CHAPTER 4 DESIGN OF PROGRAM NOLMOD 4.1 Basic considerations NOLMOD, which can be imbedded in the ENPORT-5 program, is written in standard FORTRAN V, which helps to make it readily portable. The program has been designed to allow easy implementation on a variety of computers. It has been developed as a completely separate module, which can be used as part of ENPORT-5 or used independently. When used with ENPORT, a new command has been added for invoking NOLMOD (see Appendix A for usage of program). Data are transmitted through common blocks, which can be passed through a memory or disk file interface between ENPORT and NOLMOD. Also it is user-oriented for easy operation. In ENPORT, bond graphs are taken as input data, then power directions and causality are assigned. In linear models, the next step is to enter parameters of constitutive equations (i.e. for R, C and I, TF and CY). For the nonlinear case, functional relationships between input and output variables must be defined for the constitutive 28 29 relations. NOLMOD takes over the nonlinear part at this point. Since we currently restrict the nonlinear elements to be one-ports, only one input and one output variable is required for each element. The basic relation is: output = function (input) The most important information for defining such a relationship specifically is causality and the bond types (or element types). Such information is supplied by ENPORT. Based on such information, NOLMOD makes an explicit classification of the basic equations. Both integral and derivative causality, nonlinear 2-port -TF- and -GY-, and multi-port elements are classified within the program. But some classifications are reserved for future implementation. Attention is focussed below on one-port integral storage elements and dissipators. 4.2 Classification of equations In the discussion below the following definitions are used: E = generalized effort, F = generalized flow, P = generalized momentum, and Q = genaralized displacement. According to the different types of elements and causal conditions, equations are classified into the following 30 eight types: 1. Integral C elements : E1 = FCN(Qi) 2. Integral I elements : Pi = FCN(Pi) 3. Derivative C elements : Qi = FCN(Ei) 4. Derivative I elements : pi = FCN(Fi) 5. R elements : Pi = FCN(Ei) or Ei = FCN(Fi) 6. Source elements : Ei = FCN(Time) or Pi = FCN(Time) 7. Transformers : 81 = FCN(Ej), Fj = FCN(Fi) or Pi = FCN(Fj), Ej = FCN(Ei) 8. Gyrators : Pi = FCN(Ej), Fj = FCN(Ei) or E1 = FCN(Fj), Ej = FCN(Fi) where i and j are the particular bond indices. In the current NOLMOD implementation source elements (type 6) are handled separately, since usually they are functions only of the indenpendent variable time. ' ENPORT already has an efficient procedure for handling source 31 elements, therefore NOLMOD excludes them. For the other types a function library has been built up. Once the graph causality conditions are known, the NOLMOD program classifies the system-formatted equations into the types indicated in the last section. Input and output variables are defined for every constitutive equation. In some cases the user might have chosen a different input/output orientation for a particular element. Or the causal relation is changed due to modification of the physical model, as we mentioned in Chapter 3. Therefore, for the user's convenience, he (or she) can ask the program to invert the input/output orientation. The program accepts the user-defined equation form and inverts it to obtain the necessary data for the system-formatted equations. For functions that can not be inverted, the program will prompt the user with an error message and ask for further instructions. 4.3 Function library Some commonly encountered functions are pre-programmed, available for user selection in defining input/cutout relations. A list of the library functions is shown in Table 1. Details can be found in Appendix A. The user can check the properties of the function to see if it meets the required behavior of the model. When the user inverts the LINEAR POLY SIN ASIN COS ACOS DSIN DASIN DCOS DACOS EXP ALOG ABSZ ABSQRT RCPSQR COULOM BRKPT SATUR 32 Table 1. List of library functions DEFINITION *40<|< ’4'4 K: *4 *< *4 '4 *4 K2 *4 N *< *< K: *4 K: *4 K: '4 *- \\\\ In c1*x c1*x + C2*x**2 + C3*X**3 + C4*X**4 SIN(C2*X+C3) + C4 ASIN(C2*X+C3) + C4 cos(c2*x+c3) + C4 ACOS(C2*X+C3) + C4 SIN(C2*X+C3) + C4 ASIN(C2*X+C3) + C4 COS(C2*x+C3) + C4 ACOS(C2*X+C3) + C4 EXP(C2*X+C3) + C4 ALOG(C2*X+C3) + C4 x * ABS(X) SIGN(X) * SQRT(ABS(X)) c1 / (C2+x**2) SIGN(X) C1*(x-x1), x <=x1 C2*(x-x1), x1< x , x <=x1 ((Yl-Y2)/(Xl-X2))*(X-X1), x1 WHEN FUNCTION INVERSE NOT ABAILABLE. C OPT2 I Q ---> USER ENTER QUIT FOR FUNCTION TYPE. C 0PT2 I X ---> USER ENTER X TO TERMINATE THE OPERATION. $INSERT COMFILE $INSERT COMAREA c ............................................................ OPTII'CHANGE' I25 WRITE(JLUN.I26) I26 FORMAT(/,'CHANGE ALL ? (NO):') CALL CMREAD IF(NOCMN.EQ.0)GOTO I27 IF(CMN.EQ.'X') RETURN IF((CMN.EQ.'Y').OR.(CMN.EQ.'YES'))GOTO 200 127 WRITE(JLUN,128) 128 FORMAT(/,'ENTER FUNCTION INDEX :') CALL CMREAD IF(CMN.EQ.'X')RETURN IF(NOCMN.EQ.0)GOTO 127 DECODE(80.*.CMN.ERRIIAO)MFCN IF (MFCN.LT.0) THEN PRINT A,'ERROR] INCORRECT FUNCTION NUMBER' GOTO I27 ELSE IF(MFCN.EQ.O) THEN RETURN ENDIF DD I30 JJI1,NEQS lF(|EQ2$(JJ,l) .EQ. MFCN) THEN NOF-JJ GOTO I50 ENDIF 130 CONTINUE 1A0 PRINT *,'ERROR] BAD FUNCTION LABEL' GOTO.127 150 155 I60 165 C C WRITE(JLUN,155)lEQ2$(NOF,l) FORMAT(/,'FUNCTION ',12,' NOW DEFINED AS :') CALL FCNWTR(NOF) CALL EQRVS(NOF) IF(OPT2.EQ.'X')THEN DPT2-' ' RETURN ENDIF WRITE(JLUN,165) FORMAT(/.'FUNCTION TYPE 2') CALL CMREAD IF(NOCMN.EQ.0)THEN CMN=FCNSET(IFCNTP(NOF)) FPOCMN=I LPOCMN=6 ENDIF CALL CMNCPR(FCNSET,30) IF (IFOUND.EQ.0)THEN WRITE(JLUN,900I)CMN GOTO I60 ELSE IF(IFOUND.GT.1)THEN WRITE(JLUN,9002)(CMATCH(K),K=1,IFOUND) GOTO 160 ENDIF CALL FCNLIB(NOF) IF(OPT2.EQ.'N')THEN OPT2I'U' RVS(NOF)=0. GOTO I50 ELSE IF(OPT2.EQ.'Q')THEN OPT2I'U' RETURN ENDIF GOTO A00 C-~-CHANGE ALL 200 C 210 215 220 225 CONTINUE DO 300 NOF-I,NEQS WRITE(JLUN,215)IEQ2$(NOF,1) FORMAT(/.'FUNCTION ',12.' NOW DEFINED AS :') CALL FCNWTR(NOF) CALL EQRVS(NOF) IF(OPT2.EQ.'X‘)THEN DPT2=' ' RETURN ENDIF WRITE(JLUN,225) FORMAT(/,'FUNCTION TYPE ?') CALL CMREAD C 2A IF(NOCMN.EQ.0)CMN=FCNSET(IFCNTP(NOF)) CALL CMNCPR(FCNSET,30) IF (IFOUND.EQ.0)THEN WRITE(JLUN,9OOI)CMN GOTO 220 ELSE IF(IFOUND.GT.I)THEN WRITE(JLUN,9002)(CMATCH(K),K=1,IFOUND) GOTO 220 ENDIF C CALL FCNLIB(NOF) IF(OPT2.EQ.'N')THEN OPTZI' ' RVS(NOF)-0. GOTO 210 ELSE IF(OPT2.EQ.'Q')THEN OPT2I'U' RETURN ENDIF C 300 CONTINUE C RETURN c .......... A00 CONTINUE C A05 WRITE(JLUN,AI0) AIO FORMAT(/,'CHANGE ANOTHER FUNCTION ? (YES):') CALL CMREAD IF(NOCMN.EQ.0)GOTO I27 |F((CMN.EQ.'Y').OR.(CMN.EQ.'YES'))GOTO I27 RETURN C ----- FORMAT ----- C 900I FORMAT(/,' ERROR J NO SUCH FUNCTION : ',A80) 9002 FORMAT(/.' ERROR J FUNCTIONS MIXED UP'./.(A6,' ?')) END C C---EQRVS ---------------------------------------------------- C SUBROUTINE EQRVS(K) C C ----- WRITTEN BY : TSUN-YU CHOU, SEPT. I982 c $INSERT COMFILE $INSERT COMAREA c ............................................................ IF(IPNT(I).EQ.I)WRITE(JLUN,I50)RVS(K) WRITE(JLUN,101) lOl FORMAT(/.'REVERSE INPUT AND OUTPUT ? (NO):') CALL CMREAD IF(NOCMN.EQ.0)RETURN IF((CMN.EQ.'Y').OR.(CMN.EQ.'YES'))GOTO 100 IF(CMN.EQ.'X')OPT2I'X' RETURN 100 WRITE(JLUN,110) IEQZS(K,1) llO FORMAT(/.'FUNCTION ',IZ.‘ NOW DEFINED AS :') RR-RVS(K) OPT2I'U' IF(RR.EQ.0.)THEN RVS(K)=I. ELSE IF(RR.EQ.I)THEN RVS(KlIO. ENDIF CALL FCNWTR(K) 150 FORMAT(/,'*** RVS I ',I1,' ***') C RETURN END C C---SHOW --------------------------------------------------- C SUBROUTINE SHOW C C ----- WRITTEN BY : TSUN-YU CHOU, JULY 1982 C C DISPLAY USER-DEFINED FUNCTIONS C AND SYSTEM-FORMATED FUNCTIONS C $INSERT COMFILE $INSERT COMAREA c ............................................................ OPTII'LOOK ' A25 WRITE(JLUN.A26) A26 FORMAT(/.'LOOK AT ALL ? (NO):') CALL CMREAD IF(NOCMN.EQ.0)GOTOA3O IF(CMN.EQ.'X') RETURN IF((CMN.EQ.'Y').OR.(CMN.EQ.'YES'))GOTO 560 A30 WRITE(JLUN,A32) A32 FORMAT(/.'ENTER FUNCTION INDEX :') CALL CMREAD IF(CMN.EQ.'X')RETURN IF(NOCMN.EQ.0)GOTO A30 DECODE(80.*.CMN,ERRI5A0)MFCN IF (MFCN.LT.O) THEN PRINT *,'ERROR] INCORRECT FUNCTION NUMBER' GOTO A30 ELSE IF(MFCN.EQ.O) THEN RETURN ENDIF 525 OD 530 JJI1,NEQS IF(IEQ25(JJ,1) .EQ. MFCN) THEN NOFIJJ GOTO 550 ENDIF 530 CONTINUE 5A0 PRINT *,'ERROR] BAD FUNCTION LABEL' GOTO A30 550 WRITE(JLUN,9003) IEQ2$(NOF,1) CALL FCNLOOK(NOF) GOTO 600 C ----- LOOK AT ALL FUNCTIONS. 560 CONTINUE DO 570 NOF=I,NEQS WRITE(JLUN,9003) lEQ2$(NOF,l) CALL FCNLOOK(NOF) 570 CONTINUE C RETURN c .......... 600 CONTINUE C 605 WRITE(JLUN,6lO) , 610 FORMAT(/,'LOOK AT ANOTHER FUNCTION ? (YES):') CALL CMREAD IF(NOCMN.EQ.0)GOTO A30 IF((CMN.EQ.'Y').OR.(CMN.EQ.'YES'))GOTO A30 RETURN C C ----- FORMAT ----- C 9001 F0RMAT(/.' ERROR ] N0 SUCH FUNCTION : ‘,A80) 9002 FORMAT(/.' ERROR J FUNCTIONS MIXED UP',/,(A6,' ?')) 9003 FORMAT(//,' FUNCTION ',IZ,’ :') C END C C C---FCNWTR ---------------------------------------------------- C SUBROUTINE FCNWTR(K) c C---WRITTEN BY : TSUN-YU CHOU. AUGUST I982 C $INSERT COMFILE $INSERT COMAREA c ............................................................ NNEQTPINEQTP(K) C IF(NNEQTP .LE. 6) THEN IF(RVS(K).EQ.0)THEN IF(OPTI.EQ.'DEFINE')THEN WRITE(JLUN,9OIO)CHIO(K,1),NFCN(K),NFCN(K), + CHIO(K,2),NFCN(K) ELSE IF(OPTl.EQ.'CHANGE')THEN WRITE(JLUN,9OZO)CHIO(K,1),NFCN(K),FCNSET(IFCNTP(K)), + CHIO(K,2),NFCN(K) ENDIF C ELSE IF(RVS(K).EQ.I)THEN WRITE(JLUN,9020)CH|O(K.2),NFCN(K),FCNSET(IFCNTP(K)), + CHIO(K,1),NFCN(K) ENDIF C c C ELSE IF(NNEQTP .GE. I2) THEN IF(RVS(K).EQ.O) THEN IF(OPT1.EQ.'DEFINE')THEN WRITE(JLUN.8810)CHIO(K,1),IEQZS(K,1),IEQZS(K,I), + CHIO(K,2),IEQ25(K,2), + CHIO(K,3),IEQ2$(K,2),IEQ2$(K,I), + CHIO(K,A),IEQ25(K,1) ELSE IF(OPTl.EQ.'CHANGE')THEN WRITE(JLUN,882O)CHIO(K,I),IEQ25(K,I),FCNSET(IFCNTP(K)), + CHIO(K,2),IEQZS(K,2), + CHIO(K,3),IEQ25(K,2),FCNSET(IFCNTP(K)), + CHIO(K.A),IEQ2$(K,I) ENDIF C ELSE IF(RVS(K).EQ.I) THEN WRITE(JLUN,8820)CHIO(K,2),IEQZS(K,2),FCNSET(IFCNTP(K)), + CHIO(K,l),IEQ2$(K,l), + CHIO(K,A),IEQ2$(K,I),FCNSET(IFCNTP(K)), + CHIO(K.3).IEQZS(K,2) C ENDIF c ENDIF c c ----- FORMAT ---------- C 9010 FORMAT(/.5X,A1,12,' 9020 FORMAT(/.5X,A1,12,' 8810 FORMAT(/.5X.AI.I2.' FCN',I2,' (',AI.I2.')' ) ',A6.' ('.AI.I2.')') FCN',12,' (',Al.|2.')'./. + 5X,Al,|2,' FCN',12,' (',A1,|2,')' ) 8820 FORMAT(/,5X,A1,I2,' ',A6,‘ (',A1,I2,')', + /’5x9A]’|29' ',A69' (',A‘Dlzi')') C RETURN END C C---FCNLIB --------------------------------------------------- C SUBROUTINE FCNLIB(I) C C ----- WRITTEN BY : TSUN-YU CHOU. SEPT. I982 C $INSERT COMFILE $INSERT COMAREA C C C VARIABLE : IFCNTP --- STORE FUNCTION TYPE BELOW. C C AAAAA ALL FUNCTION INDICES USED IN OTHER SUBROUTINES ARE C AAAAA ACCORDING TO THE FOLLOWING TYPE NUMBER. C C TYPE DEFINITION C ............................................................ C 01 CONST Y-CO C 02 LINEAR Y-C0+CIAX C 03 SIN Y-CIASIN(C2AX+C3) + CA C 0A COS Y-CIACOS(C2AX+C3) + CA C 05 ASIN Y-CIAASIN(C2AX+C3) + CA C C 06 ACOS Y-CIAACOS(C2AX+C3) + CA C 07 A852 Y-CIAXAABS(X) C 08 ABSQRT Y-CIASIGN(X)ASQRT(ABS(X)) C 09 EXP Y-CIAEXP(C2AX+C3) + CA C IO ALOG Y=CIAALOG(C2AX+C3) + CA C C II DSIN Y-CI/SIN(C2AX+C3) + CA C I2 DCOS Y-CI/COS(C2AX+C3) + CA C I3 DASIN Y-CI/ASIN(C2AX+C3) + CA C IA DACOS Y-CI/ACDS(C2AX+C3) + CA C I5 POLY Y-CO+CIAX+C2AXAA2+C3AXAA3+CAAXAAA C 16 COLUMB Y=CIA SIGN(X) C C 17 BRKPT Y-YI+CIA(X-XI) , X <=x1 C Y-YI+C2A(X-XI) , XI< X C C 18 SATUR YIYl , x <- XI C Y=YI+((Y2-YI)/(x2-XI))A(X-XI) , XI