Skip to content

Commit 04397cd

Browse files
committed
Test if manufactured solution is a solution
1 parent 3069a68 commit 04397cd

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

test/composite_rheology_test.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import numpy as np
2+
import sympy
23
import firedrake
34
from firedrake import (
45
as_vector,
@@ -122,3 +123,48 @@ def perturb_u(x, y):
122123
slope, intercept = np.polyfit(log_mesh_sizes, log_errors, 1)
123124
print(f"degree {degree}: log(error) ~= {slope:g} * log(dx) {intercept:+g}")
124125
assert slope > degree + 0.9
126+
127+
128+
def test_manufactured_solution():
129+
L, ρ_I, ρ_W, g = sympy.symbols("L ρ_I ρ_W g", real=True, positive=True)
130+
A_1, A_3 = sympy.symbols("A_1 A_3", real=True, positive=True)
131+
K_1, K_3 = sympy.symbols("K_1 K_3", real=True, positive=True)
132+
n, m = sympy.symbols("n m", integer=True, positive=True)
133+
134+
def strain_rate(M, A_1, A_3):
135+
return 2 * A_1 * M + 2 * A_3 * M ** 3
136+
137+
def sliding_velocity(τ, K_1, K_3):
138+
return K_1 * τ + K_3 * τ**3
139+
140+
def stress_balance(x, h, s, M, τ):
141+
return diff(h * M, x) + τ - ρ_I * g * h * diff(s, x)
142+
143+
def boundary_condition(x, u, h, s, M):
144+
d = (s - h).subs(x, L)
145+
τ_c = (ρ_I * g * h**2 - ρ_W * g * d**2) / 2
146+
return (h * M - τ_c).subs(x, L)
147+
148+
x = sympy.symbols("x", real=True)
149+
h_0, δh = sympy.symbols("h_0 δh", real=True, positive=True)
150+
h = h_0 - δh * x / L
151+
152+
# How the hell did I pick this again
153+
h_f = sympy.symbols("h_f", real=True, positive=True)
154+
d = -ρ_I / ρ_W * h.subs(x, L) + h_f
155+
ρ = (ρ_I - ρ_W * d**2 / h**2).subs(x, L)
156+
157+
u_0 = sympy.symbols("u_0", real=True, positive=True)
158+
P = ρ * g * h / 4
159+
P_0 = ρ * g * h_0 / 4
160+
δP = ρ * g * δh / 4
161+
du_1 = L * A * (P_0 ** 2 - P ** 2) / (2 * δP)
162+
du_3 = L * A * (P_0 ** (n + 1) - P ** (n + 1)) / ((n + 1) * δP)
163+
u = u_0 + du_1 + du_3
164+
165+
β = 1 / 2
166+
α = β * ρ / ρ_I * δh / L
167+
# Miracle occurs??
168+
169+
ds = (1 + β) * ρ / ρ_I * δh
170+
s = d + h.subs(x, L) + ds * (1 - x / L)

0 commit comments

Comments
 (0)