aboutsummaryrefslogtreecommitdiff
path: root/Examples/Laplace.m
diff options
context:
space:
mode:
authorIan Hinder <ian.hinder@aei.mpg.de>2011-10-13 02:39:35 +0200
committerIan Hinder <ian.hinder@aei.mpg.de>2011-10-28 18:47:57 +0200
commit8141de7d5de4ec7b6089eba4c1d0f54daa7b6aad (patch)
tree79bddb04638b8c611bc52f77d9be987d6319adf3 /Examples/Laplace.m
parent560ae3705ceb3e9cf139174ca61977f132bb982b (diff)
Add Laplace equation example
This uses Jacobi iteration to solve Laplace's equation in 2D on a square grid.
Diffstat (limited to 'Examples/Laplace.m')
-rw-r--r--Examples/Laplace.m68
1 files changed, 68 insertions, 0 deletions
diff --git a/Examples/Laplace.m b/Examples/Laplace.m
new file mode 100644
index 0000000..ad8a28f
--- /dev/null
+++ b/Examples/Laplace.m
@@ -0,0 +1,68 @@
+
+groups = {{"phi_group", {phi}}};
+
+derivatives =
+{
+ PDstandard[i_] ->
+ StandardCenteredDifferenceOperator[1,fdOrder/2,i],
+ PDstandard[i_, i_] ->
+ StandardCenteredDifferenceOperator[2,fdOrder/2,i],
+ PDstandard[i_, j_] ->
+ StandardCenteredDifferenceOperator[1,fdOrder/2,i] StandardCenteredDifferenceOperator[1,fdOrder/2,j]
+};
+
+PD = PDstandard;
+
+initialCalc =
+{
+ Name -> "Laplace_initial",
+ Schedule -> {"AT INITIAL"},
+ Where -> Interior,
+ Equations ->
+ {
+ phi -> phi0 Sum[4/(Pi n) Sin[n Pi x/Lx] Sinh[n Pi y/Lx]/Sinh[n Pi Ly/Lx], {n, 1, 1, 2}]
+ }
+};
+
+initialBoundaryCalc =
+{
+ Name -> "Laplace_initial_boundary",
+ Schedule -> {"AT INITIAL after Laplace_initial"},
+ Where -> Boundary,
+ Equations ->
+ {
+ phi -> IfThen[Abs[y-Ly]<10^-10, phi0, 0]
+ }
+};
+
+evolveCalc =
+{
+ Name -> "Laplace_relax",
+ Schedule -> {"in MoL_CalcRHS", "AT ANALYSIS"},
+ Equations ->
+ {
+ dot[phi] -> mu Euc[ui,uj] PD[phi,li,lj]
+ }
+};
+
+boundaryCalc =
+{
+ Name -> "Laplace_boundary",
+ Schedule -> {"in MoL_RHSBoundaries", "AT ANALYSIS"},
+ Where -> Boundary,
+ Equations ->
+ {
+ dot[phi] -> 0
+ }
+};
+
+
+CreateKrancThornTT[
+ groups, ".",
+ "Laplace",
+ Calculations -> {initialCalc, initialBoundaryCalc, evolveCalc, boundaryCalc},
+ PartialDerivatives -> derivatives,
+ ZeroDimensions -> {3},
+ RealParameters -> {Lx,Ly,phi0,mu},
+ IntParameters -> {{Name -> fdOrder, Default -> 2, AllowedValues -> {2, 4}}},
+ DeclaredGroups -> {"phi_group"}];