def test_simplifiy(): domain = Domain(3, 3) complex_1 = Complex(domain, 'P-', 1) space = FormSpace(complex_1, 0) Hspace = HarmonicSpace(complex_1, 0) ref = ReferenceCell(domain) f = Coefficient(space) p = Coefficient(Hspace) u = trialfunction(space) v = Argument(space, 0) kappa = Constant(1) g1 = wedge(kappa, d(u)) a = inner(wedge(kappa, d(u)), d(v)) L = inner((f - p), u) w = pullback(a) w1 = pullback(g1) w2 = simplify(w) w3 = simplify(w1) assert not isinstance(w2.integrand, Pullback) and isinstance( w.integrand, Pullback) and not isinstance(w3, Pullback) and isinstance( w1, Pullback)
def test_possion_str(): domain = Domain(3, 3) complex_1 = Complex(domain, 'P-', 1) space = FormSpace(complex_1, 0) Hspace = HarmonicSpace(complex_1, 0) f = Coefficient(space) p = Coefficient(Hspace) u = trialfunction(space) v = Argument(space, 0) kappa = Constant(1) a = inner(wedge(kappa, d(u)), d(v)) L = inner((f - p), u) print( "This test will fail if all tests are run, due to string numbers changing, use command py.test.exe test_str.py to check" ) assert ( str(a) == "∫Ω₁{(((-1∧W₀)+W₁)∧*(U))}" or str(a) == "\u222b\u03a9\u2081{((1\u2227d(U))\u2227*(d(V)))}" or str(a) == "\u222b\u03a9\u2081\u2087{((1\u2227d(U))\u2227*(d(V)))}" ) and ( str(L) == "∫Ω₁{(((-1∧W₀)+W₁)∧*(U))}" or str(L) == "\u222b\u03a9\u2081{(((-1\u2227W\u2080)+W\u2081)\u2227*(U))}" or str(L) == "\u222b\u03a9\u2081\u2087{(((-1\u2227W\u2081\u2082)+W\u2081\u2083)\u2227*(U))}" )
def test_constant(): D = Domain(2, 3) g = Constant(5) k = Constant(2.5, D) f = g * k assert f.degree == 0 and f.domain == D and f.value == 12.5 and g != k
def test_basis(): D = Domain(2, 3) f = BasisForm(D) g = BasisForm(D, 2) assert f.degree == 1 and f.domain == D and f != g
def test_space(): D = Domain(2, 3) complex_1 = Complex(D, 'P-', 2) space1 = FormSpace(complex_1, 1) space2 = complex_1[1] space3 = FormSpace(complex_1, 0) assert space1 == space2 and space1 != space3
def test_complex(): D = Domain(2, 3) complex_1 = Complex(D, 'P-', 2) complex_2 = Complex(D, 'P-', 2) complex_3 = Complex(D, 'P', 2) complex_4 = Complex(D, 'P', 1) assert complex_1 != complex_2 and complex_2 != complex_3 and complex_4 != complex_3
def test_coefficient(): D = Domain(2, 3) complex_1 = Complex(D, 'P-', 2) space = FormSpace(complex_1, 1) f = Coefficient(space) g = Coefficient(space) assert f.degree == 1 and f.domain == D and f != g
def test_argument(): D = Domain(2, 3) complex_1 = Complex(D, 'P-', 2) space = FormSpace(complex_1, 1) f = Argument(space, 1) g = Argument(space, 0) assert f.degree == 1 and g.degree == 1 and f.domain == D and g != f
def test_harmonic_space(): D = Domain(2, 3) complex_1 = Complex(D, 'P-', 2) complex_2 = Complex(D, 'P', 2) space1 = HarmonicSpace(complex_1, 1) space2 = HarmonicSpace(complex_1, 1) space3 = HarmonicSpace(complex_2, 1) space4 = HarmonicSpace(complex_1, 0) assert space1 == space2 and space2 != space3 and space3 != space4
def test_wedge(): D = Domain(2, 3) complex_1 = Complex(D, 'P-', 2) space = FormSpace(complex_1, 1) f = Coefficient(space) u = Argument(space, 1) v = Argument(space, 0) w = wedge(wedge(u, v), f) assert w.degree == 3 and w.domain == D
def test_integral_1(): domain = Domain(3, 3) complex = Complex(domain, 'P-', 2) space = FormSpace(complex, 1) G = Coefficient(space) u = Argument(space, 1) form = wedge(wedge(d(u), Constant(3)), G) a = Integral(form) assert a.domain == domain and a.integrand == form
def test_Sum(): D = Domain(2, 3) complex_1 = Complex(D, 'P-', 2) space = FormSpace(complex_1, 1) space2 = FormSpace(complex_1, 2) f = Coefficient(space2) u = Argument(space, 1) v = Argument(space, 0) w = Sum(u, v) w1 = Sum(w, f) assert w.degree == 1 and w.domain == D and w1.degree == 1 and w1.domain == D
def test_d_2(): D = Domain(2, 3) complex_1 = Complex(D, 'P-', 2) space = FormSpace(complex_1, 1) space2 = FormSpace(complex_1, 2) f = Coefficient(space2) u = Argument(space, 1) v = Argument(space, 0) w1 = d(wedge(3.45, wedge(u, v))) w2 = d(wedge(w1, f)) assert w1.degree == 3 and w1.domain == D and w2.degree == 6 and w2.domain == D
def test_wedge_2(): D = Domain(2, 3) complex_1 = Complex(D, 'P-', 2) space = FormSpace(complex_1, 1) space2 = FormSpace(complex_1, 2) f = Coefficient(space2) u = Argument(space, 1) v = Argument(space, 0) w1 = wedge(wedge(u, v), 7) w2 = wedge(w1, f) assert w1.degree == 2 and w1.domain == D and w2.degree == 4
def test_forms(): D = Domain(2, 3) complex_1 = Complex(D, 'P-', 2) space = FormSpace(complex_1, 1) f = Coefficient(space) u = Argument(space, 1) v = Argument(space, 0) w = u + v w1 = f + w w2 = w1 - v assert w2.degree == 1 and w2.domain == D
def test_d(): D = Domain(2, 3) complex_1 = Complex(D, 'P-', 2) space = FormSpace(complex_1, 1) space2 = FormSpace(complex_1, 2) f = Coefficient(space) u = Argument(space, 1) v = Argument(space2, 0) w1 = d(u) w2 = d(v) w3 = d(f) assert w1.degree == 2 and w1.domain == D and w2.degree == 3 and w3.degree == 2
def test_ints_with_forms(): D = Domain(2, 3) complex_1 = Complex(D, 'P-', 2) space = FormSpace(complex_1, 0) f = Coefficient(space) u = Argument(space, 1) v = Argument(space, 0) w = u + 1 w1 = w - v w2 = w1 - f w3 = w2 - 5 assert w3.domain == D and w3.degree == 0
def test_possion(): domain = Domain(3, 3) complex_1 = Complex(domain, 'P-', 1) space = FormSpace(complex_1, 0) Hspace = HarmonicSpace(complex_1, 0) f = Coefficient(space) p = Coefficient(Hspace) u = trialfunction(space) v = Argument(space, 0) kappa = Constant(1) a = inner(wedge(kappa, d(u)), d(v)) L = inner((f - p), u) assert L.domain == domain and L.integrand.degree == 3 and a.integrand.degree == 3
def test_pullback(): domain = Domain(3, 3) complex_1 = Complex(domain, 'P-', 1) space = FormSpace(complex_1, 0) Hspace = HarmonicSpace(complex_1, 0) ref = ReferenceCell(domain) f = Coefficient(space) p = Coefficient(Hspace) u = trialfunction(space) v = Argument(space, 0) kappa = Constant(1) g1 = wedge(kappa, d(u)) a = inner(wedge(kappa, d(u)), d(v)) L = inner((f - p), u) w = pullback(a) w1 = pullback(g1) assert w1.domain == domain and w.integrand.degree == 3 and w.domain == ref
def test_domain_and_complex(): D = Domain(3, 3) complex_1 = Complex(D, 'P-', 2) assert D != complex_1
def test_domain(): D = Domain(3, 3) D1 = Domain(3, 3) assert D != D1 and D == D