I have a set of PDE's that depend on parameters. They depend on many parameters, but for simplicity we can here assume that they depend only on one, say a
.
I want to solve them for many parameter sets, using something of the form
With[{a=1},NDSolve[...]]
But since I have many sets of parameters, and it is very inconvenient to enter them each time, I want to have something like
p1 = {a=1};
p2 = {a=Pi+4};
...
With[p1,NDSolve[...]]
With[p2,NDSolve[...]]
This clearly doesn't work because evaluating p1={a=1}
assigns a value for a
, and I don't want that (because I want to continue doing symbolic manipulations in other parts of the notebook). SetDelayed
and RuleDelayed
don't seem to work neither. Any ideas?
EDIT
I was asked to improve the description of my problem, so I try (and, on the way, thank all the people who tried to help).
The situation is this. I have a notebook that contains many formulas, which depend on many parameters. For example, I have
f[x_]:= Sin[a x^b];
g[x_]:= a/x +Exp[-b]x;
diffEq={x'[t]==f[x[t]] x[t]^2-x/g[x[t]], x[0]==123};
I want to do symbolic manipulations on the formulas, so I don't want to assign numerical values to a,b
. At the same time, I want to to solve the differential equation diffEq
, and for this I want numerical values, and I want to solve it for different sets of paramters a,b
. So I want to have variables which are assignments, something like
ass1={a->1,b->3};
ass2={a->123,b->Pi};
ass3={a->-32,b->1241203853};
...
So that I could easily do
With[ass1,NDSolve[...]]
With[ass2,NDSolve[...]]
....
and play around with the variables. I hope this better describes what I want to do.
With
be acceptable? For example,With[{p1 := {a = 1}, p2 := {a = Pi + 4}}, With[p1, Print[a]]; With[p2, Print[a]];];
$\endgroup$a=1
, etc.). I have around 12 parameters to type each time and I seek a way to circumvent it. $\endgroup$withp1 = Function[Null, With[{a = 1}, #1], HoldAll]
. This lets you writewithp1[...]
, e.g.withp1@Print[a]
gives1
. I think this might be closer to what you want, assuming you can specify your parameter sets fully in advance? $\endgroup$