Hi all,
I started to write a package for my project, where I put all the useful functions and then import the package to use them. Problems arise, so here is the function:
The function is used to generate odes to use in NDSolve
MakeSystem[var_, vart_, sys_]:=
Module[{v, vt, S, St, Sf},
v = var;
vt = vart;
S = sys;
St = S/.Thread[v-> vt];
Thread[D[vart, t] == St]]
This is an example to use the function:
dndt = r * (1 - k * n) * n - c * n * p;
dpdt = c * n * p;
var = {n, p};
vart = {n[t], p[t]}
system = {dndt, dpdt};
MakeSystem[var, vart, system]
If I put the function in the notebook, it produces exactly what I want:
n'[t] == r * (1 - k * n[t]) * n[t] - c * n[t] * p[t]
p'[t] == c * n[t] * p[t]
But if I put the function in the package, the D[vart, t] produces zeros, so the output is
0 == r * (1 - k * n[t]) * n[t] - c * n[t] * p[t]
0 == c * n[t] * p[t]
Any help?