From 54c8b4ed609962c25939ea7be55340eabd7b8e15 Mon Sep 17 00:00:00 2001 From: Will Saunders <77331509+will-saunders-ukaea@users.noreply.github.com> Date: Thu, 9 Nov 2023 16:39:31 +0000 Subject: [PATCH] updated NESO-Spack submodule prior to v0.1.0 release (#217) * Remove LAPD-specific examples and associated markdown. * updated NESO-Spack submodule prior to v0.1.0 release * Turn on energy and enstrophy output in 2Din3DHW examples. * Add some instructions for running the 2Din3DHW examples. * updated spack.yaml to reference date versioned nektar spack version * Rename H3LAPD examples readme and fiddle some whitespace to make github render it properly. * One more whitespace change for github. --------- Co-authored-by: Owen Parry --- NESO-Spack | 2 +- examples/H3LAPD/2Din3D-hw/hw.xml | 4 +- examples/H3LAPD/2Din3D-hw_fluid-only/hw.xml | 2 + examples/H3LAPD/README.md | 93 ++++++++++++ examples/H3LAPD/cuboid/cuboid.geo | 31 ---- examples/H3LAPD/cuboid/lapd.xml | 142 ------------------ examples/H3LAPD/cuboid/run_cmd_template.txt | 1 - examples/H3LAPD/full_res/full_res.geo | 48 ------- examples/H3LAPD/lapd.md | 40 ------ examples/H3LAPD/low_res/lapd.xml | 144 ------------------- examples/H3LAPD/low_res/low_res.geo | 47 ------ examples/H3LAPD/low_res/run_cmd_template.txt | 1 - spack.yaml | 2 +- 13 files changed, 99 insertions(+), 458 deletions(-) create mode 100644 examples/H3LAPD/README.md delete mode 100644 examples/H3LAPD/cuboid/cuboid.geo delete mode 100644 examples/H3LAPD/cuboid/lapd.xml delete mode 100644 examples/H3LAPD/cuboid/run_cmd_template.txt delete mode 100644 examples/H3LAPD/full_res/full_res.geo delete mode 100644 examples/H3LAPD/lapd.md delete mode 100644 examples/H3LAPD/low_res/lapd.xml delete mode 100644 examples/H3LAPD/low_res/low_res.geo delete mode 100644 examples/H3LAPD/low_res/run_cmd_template.txt diff --git a/NESO-Spack b/NESO-Spack index aacfb840..eb2fab80 160000 --- a/NESO-Spack +++ b/NESO-Spack @@ -1 +1 @@ -Subproject commit aacfb840ac310815a123d4ea385f9e672b26f601 +Subproject commit eb2fab80b23fbf1b55d84169a1f3a528203406f2 diff --git a/examples/H3LAPD/2Din3D-hw/hw.xml b/examples/H3LAPD/2Din3D-hw/hw.xml index 5c4f96a8..5553381b 100644 --- a/examples/H3LAPD/2Din3D-hw/hw.xml +++ b/examples/H3LAPD/2Din3D-hw/hw.xml @@ -38,9 +38,7 @@

d22 = 0.0

-

HW_alpha = 0.1

-

HW_kappa = 3.5

s = 0.5

@@ -61,6 +59,8 @@

t_to_SI = 2e-4

n_to_SI = 1e17

+ +

growth_rates_recording_step = 1

diff --git a/examples/H3LAPD/2Din3D-hw_fluid-only/hw.xml b/examples/H3LAPD/2Din3D-hw_fluid-only/hw.xml index 64fa3ef7..ced1ff3d 100644 --- a/examples/H3LAPD/2Din3D-hw_fluid-only/hw.xml +++ b/examples/H3LAPD/2Din3D-hw_fluid-only/hw.xml @@ -44,6 +44,8 @@

s = 0.5

num_particles_total = 0

+ +

growth_rates_recording_step = 1

diff --git a/examples/H3LAPD/README.md b/examples/H3LAPD/README.md new file mode 100644 index 00000000..d1daefc0 --- /dev/null +++ b/examples/H3LAPD/README.md @@ -0,0 +1,93 @@ +The following describes the examples that are currently available for the `H3LAPD` solver. +To build the solver executable, follow the instructions for building NESO in the [top-level README](../../README.md). + + +## Prerequisites + +In order to generate Nektar++ xml meshes, you'll need `gmsh` and `NekMesh`. +If NESO was installed with spack, then `NekMesh` should already be built. It can be added to your path with: + + export PATH=$PATH:$(spack location -i nektar%[compiler])/bin + +where [compiler] is either 'gcc' or 'oneapi' (both should work if 'spack install' completed without errors.) + +## Examples + +### 2Din3D-hw_fluid-only + +Solves the 2D Hasegawa-Wakatani (HW) equations on a 3D domain. That is: + +$$ +\begin{align} + \frac{\partial n}{\partial t} + [\phi, n] & = \alpha (\phi - n) - \kappa \frac{\partial\phi}{\partial y} \\ + \frac{\partial{\zeta}}{\partial t} + [\phi, \zeta] & = \alpha (\phi - n) +\end{align} +$$ + +where $n$ is number density, $\zeta$ is vorticity and $\phi$ is the electrostatic potential. + +$[a,b]$ is the Poisson bracket operator, defined as + +$$ +\begin{equation} + [a,b] = \frac{\partial a}{\partial x} \frac{\partial b}{\partial y} - \frac{\partial a}{\partial y} \frac{\partial +b}{\partial x}. +\end{equation} +$$ + +Generate the mesh with + + ./scripts/geo_to_xml.sh examples/H3LAPD/2Din3D-hw_fluid-only/cuboid_periodic_5x5x10.geo -x 1,2 -y 3,4 -z 5,6 -o cuboid.xml + +Then run the example with + + ./scripts/run_eg.sh H3LAPD 2Din3D-hw_fluid-only + +This script expects to find mpirun on the path and executes with four MPI ranks by default. It looks for a solver executable in the most recently modified spack-build* directory, but this can be overridden using the '-b' option. + +### 2Din3D-hw + +Solves equations (1) and (2), as in the previous example, but also enables a system of neutral particles that are coupled to the fluid solver. Particles deposit density into the (plasma) fluid via ionization. + +Generate the mesh with + + ./scripts/geo_to_xml.sh examples/H3LAPD/2Din3D-hw/cuboid_periodic_8x8x16.geo -x 1,2 -y 3,4 -z 5,6 -o cuboid.xml + +Then run the example with + + ./scripts/run_eg.sh H3LAPD 2Din3D-hw_fluid-only + +This script expects to find mpirun on the path and executes with four MPI ranks by default. It looks for a solver executable in the most recently modified spack-build* directory, but this can be overridden using the '-b' option. + +## Diagnostics +For the '2Din3DHW' equation system (used in the `2Din3D-hw` and `2Din3D-hw_fluid-only` examples), the solver can be made to output the total fluid energy ($E$) and enstrophy ($W$), which are defined as: + +$$ +\begin{align} +E&=\frac{1}{2}\int (n^2 + |\nabla\phi|^2)~\mathbf{dx}\\ +W&=\frac{1}{2}\int (n-\zeta)^2~\mathbf{dx} +\end{align} +$$ + +In the `2Din3D-hw_fluid-only` example, the expected growth rates of $E$ and $W$ can be calculated analytically according to: + +$$ +\begin{align} +\frac{dE}{dt} &= \Gamma_n-\Gamma_\alpha \\ +\frac{dW}{dt} &= \Gamma_n +\end{align} +$$ + +where + +$$ +\begin{align} +\Gamma_\alpha &= \alpha \int (n - \phi)^2~\mathbf{dx}\\ +\Gamma_n &= -\kappa \int n \frac{\partial{\phi}}{\partial y}~\mathbf{dx} +\end{align} +$$ + +To change the frequency of this output modify the value of `growth_rates_recording_step` inside the `` node in `/hw.xml`. +When that parameter is set, the values of $E$ and $W$ are written to `/growth_rates.csv` at each simulation step $^*$. Expected values of $\frac{dE}{dt}$ and $\frac{dW}{dt}$, calculated with equations (6) and (7) are also written to file, but note that these are only meaningful when particle coupling is disabled. + +$^*$ Note that the file will appear empty until the file handle is closed at the end of simulation. \ No newline at end of file diff --git a/examples/H3LAPD/cuboid/cuboid.geo b/examples/H3LAPD/cuboid/cuboid.geo deleted file mode 100644 index b552f051..00000000 --- a/examples/H3LAPD/cuboid/cuboid.geo +++ /dev/null @@ -1,31 +0,0 @@ -//=============================== Parameters ================================== -// Lengths and resolutions in each dimension -xsize = 5; -ysize = 5; -zsize = 10; -nx = 5; -ny = 5; -nz = 10; -//============================================================================= - -// Create a line in the x-direction of length , with divisions -Point(1) = {-xsize/2, -ysize/2, 0, 0.01}; -Point(2) = {xsize/2, -ysize/2, 0, 0.01}; -Line(1) = {1, 2}; -Transfinite Line(1) = nx+1; - -// Extrude split line into meshed square -sq = Extrude {0,ysize,0} {Curve{1}; Layers{ny}; Recombine;}; - -// Extrude square into a cuboid -cbd = Extrude {0,0,zsize} {Surface{sq[1]}; Layers{nz}; Recombine;}; - -// Define physical volume, surfaces for BCs -// Domain -Physical Volume(0) = {cbd[1]}; -// Long sides, parallel to z-axis -Physical Surface(1) = {cbd[2],cbd[3],cbd[4],cbd[5]}; -// Low-z square -Physical Surface(2) = {sq[1]}; -// High-z square -Physical Surface(3) = {cbd[0]}; \ No newline at end of file diff --git a/examples/H3LAPD/cuboid/lapd.xml b/examples/H3LAPD/cuboid/lapd.xml deleted file mode 100644 index 9ecbb1c9..00000000 --- a/examples/H3LAPD/cuboid/lapd.xml +++ /dev/null @@ -1,142 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - -

TimeStep = 1e3

-

NumSteps = 1e4

-

TFinal = NumSteps*TimeStep

-

IO_InfoSteps = NumSteps+1

-

IO_CheckSteps = 1

- -

Te_eV = 5.0

-

Td_eV = 0.1

-

B_T = 0.1

- -

B0 = 0.1

-

Ls = 1

-

Nref = 1e18

- -

kJ = 1.38e-23

-

keV = 8.62e-5

-

m_u = 1.67e-27

-

q_e = 1.60e-19

-

eps0_SI = 8.85e-12

- -

ts = m_u/B0/q_e

-

ns = Nref/Ls/Ls/Ls

-

ps = Nref*m_u/Ls/ts/ts

-

Us = Ls/ts

-

Tmps = m_u*Us*Us/kJ

-

phis = m_u*Us*Us/q_e

-

wci = 1./ts

- -

Bxy = B_T/B0

-

e = 1.0

-

eps0 = eps0_SI*phis*Ls/q_e

-

md = 2.0

-

me = 60./1836

-

nRef = 1e18/ns

-

qd = e

-

qelec = -e

-

Rmax = 0.4/Ls

-

Te = Te_eV/keV/Tmps

-

Td = Td_eV/keV/Tmps

-

cs = sqrt(e*(Td+Te)/(md+me))

-

vRef = cs

- -

sumvsq = 2*(Te/me+Td/md)

-

nu_ei_const = qelec^2*qd^2*(1+me/md)/(3*(PI*sumvsq)^1.5*eps0^2*me^2)

-

logLambda_const = 30-log(qd/e)+1.5*log(Te_eV)

-
- - - ne - Ge - Gd - w - phi - - - - C[1] - C[2] - C[3] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
diff --git a/examples/H3LAPD/cuboid/run_cmd_template.txt b/examples/H3LAPD/cuboid/run_cmd_template.txt deleted file mode 100644 index 2e61c35b..00000000 --- a/examples/H3LAPD/cuboid/run_cmd_template.txt +++ /dev/null @@ -1 +0,0 @@ - lapd.xml cuboid.xml \ No newline at end of file diff --git a/examples/H3LAPD/full_res/full_res.geo b/examples/H3LAPD/full_res/full_res.geo deleted file mode 100644 index a858a518..00000000 --- a/examples/H3LAPD/full_res/full_res.geo +++ /dev/null @@ -1,48 +0,0 @@ -//=================== Parameter names, chosen to match H3 ===================== -// Physical sizes / m -Rmax = 0.4; -length = 17; -// # cells in each dimension -nx = 85; // Radial resolution -ny = 16; // Parallel (on-axis) resolution -nz_target = 64; // Target Azimuthal resolution -// N.B. -// nx = 64 for H3, but they use Rmin=0.1; match approximately by increasing to nint[64 * 0.4 / (0.4-0.1)] -// nz is only a target - the actual value used is 3*Floor(nz_target,3) -//============================================================================= - -// Create a line in the x-direction of length , with divisions -Point(1) = {0, 0, 0, 0.01}; -Point(2) = {Rmax, 0, 0, 0.01}; -Line(1) = {1, 2}; -Transfinite Line(1) = nx+1; - -// Extrude split line into meshed circle -// (Rotation extrusion can only cope with angles < pi, so has to be done in three parts...) -nz_over3 = Floor(nz_target/3); -Printf("Using nz = %g",3*nz_over3); -c1[] = Extrude {{0, 0, 1}, {0, 0, 0}, 2*Pi/3} { - Curve{1}; Layers{nz_over3}; Recombine; -}; - -c2[] = Extrude {{0, 0, 1}, {0, 0, 0}, 2*Pi/3} { - Curve{c1[0]}; Layers{nz_over3}; Recombine; -}; - -c3[] = Extrude {{0, 0, 1}, {0, 0, 0}, 2*Pi/3} { - Curve{c2[0]}; Layers{nz_over3}; Recombine; -}; - -// Extrude each 1/3 of a circle to 1/3 of a cylinder -v1[] = Extrude {0,0,length} {Surface{c1[1]}; Layers{ny}; Recombine;}; -v2[] = Extrude {0,0,length} {Surface{c2[1]}; Layers{ny}; Recombine;}; -v3[] = Extrude {0,0,length} {Surface{c3[1]}; Layers{ny}; Recombine;}; - -// Label volumes and surfaces (combining the 3 azimuthally-split sections in each case) -// Whole domain volume -Physical Volume(0) = {v1[1],v2[1],v3[1]}; -// Curved boundary surface -Physical Surface(1) = {v1[3],v2[3],v3[3]}; -// Two circular boundary surfaces -Physical Surface(2) = {c1[1],c2[1],c3[1]}; -Physical Surface(3) = {v1[0],v2[0],v3[0]}; \ No newline at end of file diff --git a/examples/H3LAPD/lapd.md b/examples/H3LAPD/lapd.md deleted file mode 100644 index a3d7f1ca..00000000 --- a/examples/H3LAPD/lapd.md +++ /dev/null @@ -1,40 +0,0 @@ -## LAPD e.g. - -### Initial conditions - -[Herme-3](https://github.com/bendudson/hermes-3) initialises $n_e$ with -$$ - 0.1~e^{-x^2} + 10^{-5}~(\mathrm{mixmode}(z) + \mathrm{mixmode}(4*z - x)) -$$ - -From the [BOUT++ docs](https://bout-dev.readthedocs.io/en/latest/user_docs/variable_init.html#initialisation-of-time-evolved-variables): - - The ``mixmode(x)`` function is a mixture of Fourier modes of the form: - - $$ - \mathrm{mixmode}(x) = \sum_{i=1}^{14} \frac{1}{(1 + - |i-4|)^2}\cos[ix + \phi(i, \mathrm{seed})] - $$ - - where $\phi$ is a random phase between $-\pi$ and - $+\pi$, which depends on the seed. The factor in front of each - term is chosen so that the 4th harmonic ($i=4$) has the highest - amplitude. This is useful mainly for initialising turbulence - simulations, where a mixture of mode numbers is desired. - -OP: Not clear what ICs for fields other than $n_e$ are... - ---- - -### Electron-ion collision frequency -From eqns 133,134 in the equations doc: -$$ -\nu_{e,i} = \frac{|q_e||q_i|n_{i}{\rm log}\Lambda(1+m_e/m_i)}{3\pi^{3/2}\epsilon_0^{2}m_e^2(v_e^2+v_i^2)^{3/2}} -$$ -with -$$ -\begin{align} -{\rm log}\Lambda =&~30 − 0.5 \ln n_e − \ln Z_i + 1.5 \ln Te \\ -{\rm log}\Lambda =&~34.14 − 0.5 \ln n_e -\end{align} -$$ \ No newline at end of file diff --git a/examples/H3LAPD/low_res/lapd.xml b/examples/H3LAPD/low_res/lapd.xml deleted file mode 100644 index b209fba0..00000000 --- a/examples/H3LAPD/low_res/lapd.xml +++ /dev/null @@ -1,144 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - -

TimeStep = 1e3

-

NumSteps = 1e4

-

TFinal = NumSteps*TimeStep

-

IO_InfoSteps = NumSteps+1

-

IO_CheckSteps = 1

- -

Te_eV = 5.0

-

Td_eV = 0.1

-

B_T = 0.1

- -

B0 = 0.1

-

Ls = 1

-

Nref = 1e18

- -

kJ = 1.38e-23

-

keV = 8.62e-5

-

m_u = 1.67e-27

-

q_e = 1.60e-19

-

eps0_SI = 8.85e-12

- -

ts = m_u/B0/q_e

-

ns = Nref/Ls/Ls/Ls

-

ps = Nref*m_u/Ls/ts/ts

-

Us = Ls/ts

-

Tmps = m_u*Us*Us/kJ

-

phis = m_u*Us*Us/q_e

-

wci = 1./ts

- -

Bxy = B_T/B0

-

e = 1.0

-

eps0 = eps0_SI*phis*Ls/q_e

-

md = 2.0

-

me = 60./1836

-

n_floor_fac = 1e-5

-

nRef = 1e18/ns

-

qd = e

-

qelec = -e

-

Rmax = 0.4/Ls

-

Te = Te_eV/keV/Tmps

-

Td = Td_eV/keV/Tmps

-

cs = sqrt(e*(Td+Te)/(md+me))

-

vRef = cs

- -

sumvsq = 2*(Te/me+Td/md)

-

nu_ei_const = qelec^2*qd^2*(1+me/md)/(3*(PI*sumvsq)^1.5*eps0^2*me^2)

-

logLambda_const = 30-log(qd/e)+1.5*log(Te_eV)

-
- - - ne - Ge - Gd - w - phi - - - - C[1] - C[2] - C[3] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
diff --git a/examples/H3LAPD/low_res/low_res.geo b/examples/H3LAPD/low_res/low_res.geo deleted file mode 100644 index 36f4a49a..00000000 --- a/examples/H3LAPD/low_res/low_res.geo +++ /dev/null @@ -1,47 +0,0 @@ -//=================== Parameter names, chosen to match H3 ===================== -// Physical sizes / m -Rmax = 0.4; -length = 17; -// # cells in each dimension -nx = 6; // Radial resolution -ny = 3; // Parallel (on-axis) resolution -nz_target = 6; // Target Azimuthal resolution -// N.B. -// nz is only a target - the actual value used is 3*Floor(nz_target,3) -//============================================================================= - -// Create a line in the x-direction of length , with divisions -Point(1) = {0, 0, 0, 0.01}; -Point(2) = {Rmax, 0, 0, 0.01}; -Line(1) = {1, 2}; -Transfinite Line(1) = nx+1; - -// Extrude split line into meshed circle -// (Rotation extrusion can only cope with angles < pi, so has to be done in three parts...) -nz_over3 = Floor(nz_target/3); -Printf("Using nz = %g",3*nz_over3); -c1[] = Extrude {{0, 0, 1}, {0, 0, 0}, 2*Pi/3} { - Curve{1}; Layers{nz_over3}; Recombine; -}; - -c2[] = Extrude {{0, 0, 1}, {0, 0, 0}, 2*Pi/3} { - Curve{c1[0]}; Layers{nz_over3}; Recombine; -}; - -c3[] = Extrude {{0, 0, 1}, {0, 0, 0}, 2*Pi/3} { - Curve{c2[0]}; Layers{nz_over3}; Recombine; -}; - -// Extrude each 1/3 of a circle to 1/3 of a cylinder -v1[] = Extrude {0,0,length} {Surface{c1[1]}; Layers{ny}; Recombine;}; -v2[] = Extrude {0,0,length} {Surface{c2[1]}; Layers{ny}; Recombine;}; -v3[] = Extrude {0,0,length} {Surface{c3[1]}; Layers{ny}; Recombine;}; - -// Label volumes and surfaces (combining the 3 azimuthally-split sections in each case) -// Whole domain volume -Physical Volume(0) = {v1[1],v2[1],v3[1]}; -// Curved boundary surface -Physical Surface(1) = {v1[3],v2[3],v3[3]}; -// Two circular boundary surfaces -Physical Surface(2) = {c1[1],c2[1],c3[1]}; -Physical Surface(3) = {v1[0],v2[0],v3[0]}; \ No newline at end of file diff --git a/examples/H3LAPD/low_res/run_cmd_template.txt b/examples/H3LAPD/low_res/run_cmd_template.txt deleted file mode 100644 index 8466450b..00000000 --- a/examples/H3LAPD/low_res/run_cmd_template.txt +++ /dev/null @@ -1 +0,0 @@ -mpirun -np lapd.xml low_res.xml \ No newline at end of file diff --git a/spack.yaml b/spack.yaml index 7ce7cb1d..cdaaf037 100644 --- a/spack.yaml +++ b/spack.yaml @@ -31,6 +31,6 @@ spack: path: . spec: neso@working nektar: - spec: nektar@5.3.0-2e0fb8 + spec: nektar@5.2.0-2022-09-03 neso-particles: spec: neso-particles@working