Overview
Comment:Initial revision
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: 5a522e1ac882aac72436aa6dae7fdf299f1354efa4076bbf4a2e24e908d2e7c5
User & Date: gawthrop@users.sourceforge.net on 2000-04-08 10:43:26
Other Links: branch diff | manifest | tags
Context
2000-04-10
09:40:13
Initial revision check-in: 056069352f user: gawthrop@users.sourceforge.net tags: origin/master, trunk
2000-04-08
10:43:26
Initial revision check-in: 5a522e1ac8 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
10:23:38
Added -noglobal option check-in: 91565f88a1 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
Changes

Added mttroot/mtt/bin/trans/mtt_make_sim version [ccc5a344ef].





































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#! /bin/sh

   ###################################### 
   ##### Model Transformation Tools #####
   ######################################


# Bourne shell script: mtt_make_sim
# Copyright (C) 2000 by Peter J. Gawthrop

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################

# Tell user
Sys=$1
method=$2

if [ -z "$method" ]; then
    method=implicit    
fi
#
echo  "Creating $1_sim.m with $method integration method"

if [ $method = "implicit" ]; then
    ode=cse
    odeo=cseo
else
    ode=ode
    odeo=odeo
fi

# Find system constants
Nx=`mtt_getsize $Sys x` # States
Nu=`mtt_getsize $Sys u` # Inputs 
Ny=`mtt_getsize $Sys y` # Inputs 

# Header
lang_header -noglobal $1 sim m 'x0,u,t,par' '[y,x]' > $1_sim.m

cat >> $1_sim.m <<EOF
  ## Initialise
  ui  = zero_input($Nu);	# Zero the input
  xi = x0;	        # Read in initial state


  yi = $1_cseo(xi,ui,t(1),par);    # First output

  ##Sizes
  N = length(t);

  ## Initialise  arrays   
  x = zeros($Nx,N);
  y = zeros($Ny,N);
  y(:,1) = yi(:);
  A = zeros($Nx,$Nx);
  Ax = zeros($Nx,1);
  dx = zeros($Nx,1);

  ## Step size
  dt = t(2)-t(1);

  for i = 1:N
    ti = t(i);
    ui = u(i);
    y(:,i) = yi;
    x(:,i) = xi;
    dxi = $1_cse(xi,ui,ti,par); # State derivative
    A = $1_smxa(xi,ui,dt,par);	# (I-Adt)
    A = reshape(A,$Nx,$Nx);
    Ax = $1_smxax(xi,ui,dt,par);	# (I-Adt)x
    #open = eval(sprintf("%s_switchopen(x);", system_name));        # Open switches
    #x = mtt_implicit(x,dx,A,Ax,dt,$Nx,zeros(20,1)); # Implicit update
    xi = A\(Ax + dxi*dt);        # Implicit update
    yi = $1_cseo(xi,ui,ti,par);    # Output 
  endfor;			

endfunction
EOF


MTT: Model Transformation Tools
GitHub | SourceHut | Sourceforge | Fossil RSS ]