diff options
author | Josef Kemetmüller <josef.kemetmueller@gmail.com> | 2020-03-11 22:22:39 +0100 |
---|---|---|
committer | Jon <jonringer@users.noreply.github.com> | 2020-03-19 21:48:27 -0700 |
commit | bffc7492104bb744ae059602848db1e9d708ce82 (patch) | |
tree | 6901a0d24f081c77a52939c3e42572f5ba3b10f0 /nixos/tests/fenics.nix | |
parent | fbb273c5fe8634a1ffe246f41eafe2ae492f6cc9 (diff) |
nixosTests.fenics: Add basic test
Diffstat (limited to 'nixos/tests/fenics.nix')
-rw-r--r-- | nixos/tests/fenics.nix | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/nixos/tests/fenics.nix b/nixos/tests/fenics.nix new file mode 100644 index 000000000000..7252d19e4e65 --- /dev/null +++ b/nixos/tests/fenics.nix @@ -0,0 +1,50 @@ +import ./make-test-python.nix ({ pkgs, ... }: + +let + fenicsScript = pkgs.writeScript "poisson.py" '' + #!/usr/bin/env python + from dolfin import * + + mesh = UnitSquareMesh(4, 4) + V = FunctionSpace(mesh, "Lagrange", 1) + + def boundary(x): + return x[0] < DOLFIN_EPS or x[0] > 1.0 - DOLFIN_EPS + + u0 = Constant(0.0) + bc = DirichletBC(V, u0, boundary) + + u = TrialFunction(V) + v = TestFunction(V) + f = Expression("10*exp(-(pow(x[0] - 0.5, 2) + pow(x[1] - 0.5, 2)) / 0.02)", degree=2) + g = Expression("sin(5*x[0])", degree=2) + a = inner(grad(u), grad(v))*dx + L = f*v*dx + g*v*ds + + u = Function(V) + solve(a == L, u, bc) + print(u) + ''; +in +{ + name = "fenics"; + meta = { + maintainers = with pkgs.stdenv.lib.maintainers; [ knedlsepp ]; + }; + + nodes = { + fenicsnode = { pkgs, ... }: { + environment.systemPackages = with pkgs; [ + gcc + (python3.withPackages (ps: with ps; [ fenics ])) + ]; + virtualisation.memorySize = 512; + }; + }; + testScript = + { nodes, ... }: + '' + start_all() + node1.succeed("${fenicsScript}") + ''; +}) |