source: trunk/sample/miscellaneous/sample_pend.mso @ 987

Last change on this file since 987 was 542, checked in by Argimiro Resende Secchi, 14 years ago

Adding polar coordinate for pendulum sample.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.3 KB
Line 
1#*-------------------------------------------------------------------
2* EMSO Model Library (EML) Copyright (C) 2004 - 2007 ALSOC.
3*
4* This LIBRARY is free software; you can distribute it and/or modify
5* it under the therms of the ALSOC FREE LICENSE as available at
6* http://www.enq.ufrgs.br/alsoc.
7*
8* EMSO Copyright (C) 2004 - 2007 ALSOC, original code
9* from http://www.rps.eng.br Copyright (C) 2002-2004.
10* All rights reserved.
11*
12* EMSO is distributed under the therms of the ALSOC LICENSE as
13* available at http://www.enq.ufrgs.br/alsoc.
14*
15*--------------------------------------------------------------------
16* FlowSheet with the Model for the index three pendulum
17* in Cartesian coordinates.
18*--------------------------------------------------------------------
19* Author: Rafael de Pelegrini Soares
20* $Id: sample_pend.mso 542 2008-06-21 16:01:41Z arge $
21*-------------------------------------------------------------------*#
22
23using "types.mso";
24
25FlowSheet pend
26        PARAMETERS
27        g     as acceleration (Brief = "Gravity acceleration");
28        L     as length (Brief = "Pendulum cable length");
29       
30        VARIABLES
31        x   as length_delta(Brief="Position x");
32        y   as length_delta(Brief="Position y");
33        w   as velocity(Brief = "Velocity for x");
34        z   as velocity(Brief = "Velocity for y");
35        T   as Real(Brief = "Tension on cable",Default=10,Unit='1/s^2');
36       
37        EQUATIONS
38        "Velocity on x"
39        diff(x)=w;
40       
41        "Velocity on y"
42        diff(y)=z;
43       
44        "Tension on x"
45        diff(w)=T*x;
46       
47        "Tension on y"
48        diff(z)=T*y-g;
49       
50        "Position Constraint"
51        x^2+y^2=L^2;
52       
53        SET
54        g     = 9.8 * 'm/s^2';
55        L     = 0.9 * 'm';
56
57        INITIAL
58        "Initial Position x"
59        x = 0.9 * 'm';
60
61        "Initial x Velocity"
62        w = 0 * 'm/s';
63       
64        OPTIONS
65        TimeStep = 0.1;
66        TimeEnd = 36;
67        Integration = "original"; # original, index0, or index1
68
69        NLASolver(
70                RelativeAccuracy = 1e-8,
71                AbsoluteAccuracy = 1e-9
72        );
73        DAESolver(
74                #File = "dasslc",
75                #File = "dassl", # fail when "original" (high-index)
76                File = "mebdf",
77                #File = "pside",
78                #File = "sundials", # fail when "original" (high-index)
79                RelativeAccuracy = 1e-6,
80                AbsoluteAccuracy = 1e-8
81        );
82        SparseAlgebra = true;
83end
84
85
86FlowSheet pend_polar
87        PARAMETERS
88        g     as acceleration (Brief = "Gravity acceleration");
89        L     as length (Brief = "Pendulum cable length");
90       
91        VARIABLES
92        phi   as angle (Brief="Angle");
93        omega as frequency (Brief="Angular velocity", Lower=-100);
94        x     as length_delta(Brief="Position x");
95        y     as length_delta(Brief="Position y");
96        w     as velocity(Brief = "Velocity for x");
97        z     as velocity(Brief = "Velocity for y");
98        T     as Real(Brief = "Tension on cable",Default=10,Unit='1/s^2');
99       
100        EQUATIONS
101        "x Position"
102        x = L*sin(phi);
103
104        "y Position"
105        y = -L*cos(phi);
106
107        "Velocity on x"
108        w = L*omega*cos(phi);
109       
110        "Velocity on y"
111        z = L*omega*sin(phi);
112       
113        "Tension"
114        T = -g*cos(phi)/L-omega^2;
115
116        "Angular velocity"
117        diff(phi) = omega*'rad';
118
119        "Angular acceleration"
120        diff(omega) = -g*sin(phi)/L;
121
122        SET
123        g     = 9.8 * 'm/s^2';
124        L     = 0.9 * 'm';
125
126        INITIAL
127        "Initial Position x"
128        x = 0.9 * 'm';
129
130        "Initial x Velocity"
131        w = 0 * 'm/s';
132       
133        OPTIONS
134        TimeStep = 0.1;
135        TimeEnd = 36;
136        Integration = "original"; # original, index0, or index1
137
138        NLASolver(
139                RelativeAccuracy = 1e-8,
140                AbsoluteAccuracy = 1e-9
141        );
142        DAESolver(
143                #File = "dasslc",
144                File = "dassl", # fail when "original" (high-index)
145                #File = "mebdf",
146                #File = "pside",
147                #File = "sundials", # fail when "original" (high-index)
148                RelativeAccuracy = 1e-6,
149                AbsoluteAccuracy = 1e-8
150        );
151        SparseAlgebra = true;
152end
Note: See TracBrowser for help on using the repository browser.