aboutsummaryrefslogtreecommitdiff
path: root/Examples/SimpleWaveCaKernel.m
blob: fee9df5a737cc4692c8544090a373d86adcff702 (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
47
48
49
50
51
52
53
54
<< "KrancThorn.m";

groups = {{"phi_g", {phi}}, {"pi_g", {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)]
  }
};

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


integrateCalc = 
{
  Name -> "rk1",
  Schedule -> {"at EVOL after calc_rhs"},
  Where -> Interior,
  Equations ->
  {
    phi -> phi + dt dot[phi]
    pi -> pi + dt dot[pi]
  }
};

CreateKrancThornTT[groups, ".", 
  "SimpleWaveCaKernel", 
  Calculations -> {initialSineCalc, evolveCalc, integrateCalc},
  PartialDerivatives -> derivatives,
  UseCaKernel -> True,
  DeclaredGroups -> {"phi_g","pi_g"}];