Differences From Artifact [d3a008bc98]:

To Artifact [2a9d7b1d9e]:


1
2
3
4
5
6
7
8
9
10
11



12
13
14
15
16
17
18
#! /bin/sh

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

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



## Revision 1.81  2002/07/11 13:00:23  geraint
## Declared more function arguments to be "const" - improves compiler optimisation.
##
## Revision 1.80  2002/05/22 09:35:49  geraint
## Added insertor variable to stop sh-mode font-lock from getting hopelessly confused by embedded C++.
##
## Revision 1.79  2002/05/20 13:42:31  gawthrop











>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#! /bin/sh

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

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.82  2002/07/24 14:00:12  geraint
## Corrected arguments passed to mtt_write when dumping data (sigint).
##
## Revision 1.81  2002/07/11 13:00:23  geraint
## Declared more function arguments to be "const" - improves compiler optimisation.
##
## Revision 1.80  2002/05/22 09:35:49  geraint
## Added insertor variable to stop sh-mode font-lock from getting hopelessly confused by embedded C++.
##
## Revision 1.79  2002/05/20 13:42:31  gawthrop
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
    f = feval ("mtt_dassl", args, 1);
    return f(0).${vector_value} ();
#endif // ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX))
}

#if ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX))
ColumnVector
mtt_residual (const ColumnVector &X,
	      const ColumnVector &DX,
	      double t,
	      int &ires)
{
#elif (CODEGENTARGET == OCTAVEDLD)
DEFUN_DLD (mtt_residual, args, , "mtt_residual")
{
    static ColumnVector	X  (MTTNX+MTTNYZ);
    static ColumnVector	DX (MTTNX+MTTNYZ);
    static double      	t;
    static int		&ires;

    X  = args(0).${vector_value} ();
    DX = args(1).${vector_value} ();
    t  = args(2).double_value ();
    ires = static_cast<int>(args(3).double_value ());
#endif // ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX))








|










|







826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
    f = feval ("mtt_dassl", args, 1);
    return f(0).${vector_value} ();
#endif // ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX))
}

#if ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX))
ColumnVector
Fmtt_residual (const ColumnVector &X,
	      const ColumnVector &DX,
	      double t,
	      int &ires)
{
#elif (CODEGENTARGET == OCTAVEDLD)
DEFUN_DLD (mtt_residual, args, , "mtt_residual")
{
    static ColumnVector	X  (MTTNX+MTTNYZ);
    static ColumnVector	DX (MTTNX+MTTNYZ);
    static double      	t;
    static int		ires;

    X  = args(0).${vector_value} ();
    DX = args(1).${vector_value} ();
    t  = args(2).double_value ();
    ires = static_cast<int>(args(3).double_value ());
#endif // ((CODEGENTARGET == STANDALONE) || (CODEGENTARGET == MATLABMEX))

1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
    row = 0;
    fcputime.close();
    }
}

void
${sys}_ode2odes (const ColumnVector &state0,
		 const ColumnVector &numpar,
		 const ColumnVector &simpar)
{
  static double first, dt, last, stepfactor;
  first		= simpar (0);
  last		= simpar (1);
  dt		= simpar (2);
  stepfactor	= simpar (3);







|







1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
    row = 0;
    fcputime.close();
    }
}

void
${sys}_ode2odes (const ColumnVector &state0,
		 const ColumnVector &par,
		 const ColumnVector &simpar)
{
  static double first, dt, last, stepfactor;
  first		= simpar (0);
  last		= simpar (1);
  dt		= simpar (2);
  stepfactor	= simpar (3);
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
  for (register int i = 0; i < MTTNX; i++)
    {
      x (i) = state0 (i);
    }

  for (register int j = 0, i = 1; i <= ilast; i++)
    {
      u	= mtt_input (x, y, t, numpar);
      y	= mtt_output (x, u, t, numpar);
      if (0 == j)
	{
           mtt_write (t, x, y, first, nrows);
	}
EOF
case "$method" in
    "rk4")







|
|







1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
  for (register int i = 0; i < MTTNX; i++)
    {
      x (i) = state0 (i);
    }

  for (register int j = 0, i = 1; i <= ilast; i++)
    {
      u	= mtt_input (x, y, t, par);
      y	= mtt_output (x, u, t, par);
      if (0 == j)
	{
           mtt_write (t, x, y, first, nrows);
	}
EOF
case "$method" in
    "rk4")
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
          t2 = t + ddt;

        ColumnVector
          x1 (x),
          x2 (x),
          x3 (x);

        k1 = ddt * mtt_rate (x , u, t , numpar); x1 += k1 * 0.5;
        k2 = ddt * mtt_rate (x1, u, t1, numpar); x2 += k2 * 0.5;
        k3 = ddt * mtt_rate (x2, u, t1, numpar); x3 += k3;
        k4 = ddt * mtt_rate (x3, u, t2, numpar);
        dx = (k1 + 2.0 * (k2 + k3) + k4) / (6.0 * ddt);
      }
EOF
    ;;
    "dassl")
    ;;
    "implicit")
	cat << EOF >> $filename
      dx = mtt_rate (x, u, t, numpar);
      AA = mtt_smxa (x, u, ddt, numpar);
      AAx = mtt_smxax (x, u, ddt, numpar);
EOF
    ;;
    "euler" | *)
	cat << EOF >> $filename
      dx = mtt_rate (x, u, t, numpar);
EOF
    ;;
esac

## Common stuff
cat <<EOF >> $filename
      open_switches = mtt_logic (x, u, t, numpar);
      x =  $algorithm; 
      t += ddt;
      j++;
      j = (j == static_cast<int> (stepfactor)) ? 0 : j;
    }

}







|
|
|
|








|
|
|




|






|







1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
          t2 = t + ddt;

        ColumnVector
          x1 (x),
          x2 (x),
          x3 (x);

        k1 = ddt * mtt_rate (x , u, t , par); x1 += k1 * 0.5;
        k2 = ddt * mtt_rate (x1, u, t1, par); x2 += k2 * 0.5;
        k3 = ddt * mtt_rate (x2, u, t1, par); x3 += k3;
        k4 = ddt * mtt_rate (x3, u, t2, par);
        dx = (k1 + 2.0 * (k2 + k3) + k4) / (6.0 * ddt);
      }
EOF
    ;;
    "dassl")
    ;;
    "implicit")
	cat << EOF >> $filename
      dx = mtt_rate (x, u, t, par);
      AA = mtt_smxa (x, u, ddt, par);
      AAx = mtt_smxax (x, u, ddt, par);
EOF
    ;;
    "euler" | *)
	cat << EOF >> $filename
      dx = mtt_rate (x, u, t, par);
EOF
    ;;
esac

## Common stuff
cat <<EOF >> $filename
      open_switches = mtt_logic (x, u, t, par);
      x =  $algorithm; 
      t += ddt;
      j++;
      j = (j == static_cast<int> (stepfactor)) ? 0 : j;
    }

}

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