aboutsummaryrefslogtreecommitdiff
path: root/Examples/SimpleWaveODE.m
blob: 636d1f9f7b96c6d9afea720b61abc8034614a6e8 (plain)
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
<< "KrancThorn.m";

groups = {{"ode_group", {a, b}}, {"evolved_group", {phi, pi}}};

derivatives =
{
  PDstandard2nd[i_] -> StandardCenteredDifferenceOperator[1,1,i],
  PDstandard2nd[i_, i_] -> StandardCenteredDifferenceOperator[2,1,i]
};

PD = PDstandard2nd;

initialSineCalc = 
{
  Name -> "initial_sine",
  Schedule -> {"AT INITIAL"},
  Equations -> 
  {
    phi -> Sin[2 Pi (x - t)],
    pi -> -2 Pi Cos[2 Pi (x - t)],
    a -> 0, b -> 1
  }
};

evolveCalc = 
{
  Name -> "calc_rhs",
  Schedule -> {"in MoL_CalcRHS"},
  Where -> Interior,
  Equations ->
  {
    dot[phi] -> pi,
    dot[pi]  -> a Euc[ui,uj] PD[phi,li,lj],
    dot[a] -> b,
    dot[b] -> -a
  }
};

CreateKrancThornTT[groups, ".", 
  "SimpleWaveODE", 
  Calculations -> {initialSineCalc, evolveCalc},
  PartialDerivatives -> derivatives,
  DeclaredGroups -> {"evolved_group"},
  ODEGroups -> {"ode_group"}
];