Skip to content

Commit

Permalink
Advection field in RP instead of XY
Browse files Browse the repository at this point in the history
For the merge ---------------------------------------------------------

Add in addition of the advection field in XY, an advection field in RP.
Add a AdvectionFieldFinder class which computes advection field along XY and
along RP.
Modify BslAdvectionRP class to add an operator for the advection field on RP
as input.
Remove the VlasovPoissonSolver class.

For the MR ------------------------------------------------------------

The advection operator will take the advection field in RP instead of XY.

TO DO -----------------------------------------------------------------
- [x] Check documentations and formulas;
- [x] Remove vlasovpoissonsolver.hpp and associated documentation;
- [x] Add tests;
- [x] Remove modifications made for the diocotron simulation, only use the advection field in XY;
- [x] Add a case in the predictor-corrector operators? or these operators are made for the guiding-center case and better work with only  advection field in XY;

- Create a function set_initialization which return exact_rho.initialisation and exact_rho.equilibrium in diocotron simulation?
- Check if the following had been done or has to be done:
* geometry_PC -> foot finder
* advect_feet -> foot finder
* compute advection field -> PseudoCartesian()
* remove AdvectionDomain and give PseudoCartesian mapping instead

See merge request gysela-developpers/gyselalibxx!309

--------------------------------------------

Co-authored-by: Pauline Vidal <[email protected]>
Co-authored-by: Emily Bourne <[email protected]>
Co-authored-by: Thomas Padioleau <[email protected]>
Co-authored-by: Baptiste LEGOUIX <[email protected]>
  • Loading branch information
5 people committed Mar 20, 2024
1 parent a2aa7e5 commit dcdba00
Show file tree
Hide file tree
Showing 27 changed files with 2,060 additions and 599 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# ---------------------------------------------------------------------------
current_folder = Path(__file__).parent

perturb_defaults = {'dioctotron':False, 'vortex_merger':True}
perturb_defaults = {'diocotron':False, 'vortex_merger':True}

parser = argparse.ArgumentParser(description="Plot and save the density and the electrical potential solutions of a given output folder.")

Expand Down
6 changes: 2 additions & 4 deletions simulations/geometryRTheta/diocotron/diocotron.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
#include "spline_interpolator_2d_rp.hpp"
#include "spline_quadrature.hpp"
#include "trapezoid_quadrature.hpp"
#include "vlasovpoissonsolver.hpp"



Expand Down Expand Up @@ -200,10 +199,9 @@ int main(int argc, char** argv)

AdvectionPhysicalDomain advection_domain(mapping);

SplineFootFinder
find_feet(time_stepper, advection_domain, grid, builder, spline_evaluator_extrapol);
SplineFootFinder find_feet(time_stepper, advection_domain, builder, spline_evaluator_extrapol);

BslAdvectionRP advection_operator(interpolator, find_feet);
BslAdvectionRP advection_operator(interpolator, find_feet, mapping);



Expand Down
2 changes: 1 addition & 1 deletion simulations/geometryRTheta/diocotron/params.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Mesh:

Time:
delta_t: 0.1
final_T: 100.0
final_T: 70.

Perturbation:
charge_Q: 0
Expand Down
6 changes: 2 additions & 4 deletions simulations/geometryRTheta/vortex_merger/vortex_merger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
#include "spline_interpolator_2d_rp.hpp"
#include "spline_quadrature.hpp"
#include "trapezoid_quadrature.hpp"
#include "vlasovpoissonsolver.hpp"
#include "vortex_merger_equilibrium.hpp"
#include "vortex_merger_initialization.hpp"

Expand Down Expand Up @@ -181,10 +180,9 @@ int main(int argc, char** argv)

AdvectionPhysicalDomain advection_domain(mapping);

SplineFootFinder
find_feet(time_stepper, advection_domain, grid, builder, spline_evaluator_extrapol);
SplineFootFinder find_feet(time_stepper, advection_domain, builder, spline_evaluator_extrapol);

BslAdvectionRP advection_operator(interpolator, find_feet);
BslAdvectionRP advection_operator(interpolator, find_feet, mapping);



Expand Down
1 change: 1 addition & 0 deletions src/geometryRTheta/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ add_subdirectory(initialization)
add_subdirectory(interpolation)
add_subdirectory(poisson)
add_subdirectory(time_solver)
add_subdirectory(advection_field)


6 changes: 4 additions & 2 deletions src/geometryRTheta/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ The `geometryRTheta` folder contains all the code describing methods which are s

- [advection](./advection/README.md) - Code describing advection operator and time integration methods used on 2D polar domain.

- [advection\_field](./advection_field/README.md) - Code describing computation of the advection field given to the advection operator.

- [geometry](./geometry/README.md) - All the dimension tags used for a gyrokinetic semi-Lagrangian simulation in a curvilinear geometry.

- [initialization](./initialization/README.md) - Initializes the simulations on a 2D polar domain.

- [interpolation](./interpolation/README.md) - Code describing interpolation methods on 2D polar domain.

- [poisson](./poisson/README.md) - Code describing the polar Poisson solver.

- [initialization](./initialization/README.md) - Initializes the simulations on a 2D polar domain.

- [time\_solver](./time_solver/README.md) - The methods to solve in time the equations system.


146 changes: 130 additions & 16 deletions src/geometryRTheta/advection/README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
# Advection operator

## Advection operator

### Studied equation
## Studied equation

The studied equation is the following 2D transport equation type :
```math
\partial_t f(t,x,y) + A(t,x,y)\cdot\nabla f(t,x,y) = 0,
```

with $`f(0,x,y) = f_0(x,y)`$ and $A$ the advection field.

**We want to solve it on a polar grid.**
with $`f(0,x,y) = f_0(x,y)`$ and *A* the advection field.

**We want to solve it on a polar grid so we have:** $`(t,x,y) = (t,x(r,\theta),y(r,\theta))`$.

### Backward Semi-Lagrangian method
## Backward Semi-Lagrangian method

The method used to solve the equation is a Backward Semi-Lagrangian method (BSL).
It uses the conservation along the characteristics property:
Expand All @@ -38,7 +35,7 @@ So to compute the advected function at the next time step,



### Time integration methods
## Time integration methods

There are multiple time integration methods available which are implemented in the ITimeStepper child classes. For example:
- Explicit Euler method: Euler;
Expand All @@ -53,15 +50,15 @@ We are listing the different schemes for this equation $`\partial_t X (t) = A_x(
We write $X (t) = X (t; s, x, y)$, $X^n = X(t^n)$ and $A^n(X) = A(t^n, X)$ for a time discretisation $`\{t^n; t^n > t^{n-1}, \forall n\}_n`$.


#### Explicit Euler method
### Explicit Euler method

- Scheme:
$X^n = X^{n+1} - dt A^{n+1}(X^{n+1})$

- Convergence order : 1.


#### Crank-Nicolson method
### Crank-Nicolson method

- Scheme:
$X^{k+1} = X^{n+1} - \frac{dt}{2} \left( A^{n+1}(X^{n+1}) + A^k(X^k) \right)$ and
Expand All @@ -70,7 +67,7 @@ $X^{n+1} = X^{k+1}$ once converged.
- Convergence order : 2.


#### RK3 method
### RK3 method

- Scheme:
$`X^n = X^{n+1} - \frac{dt}{6} \left( k_1 + 4 k_2 + k_3 \right)`$
Expand All @@ -83,7 +80,7 @@ $`X^n = X^{n+1} - \frac{dt}{6} \left( k_1 + 4 k_2 + k_3 \right)`$



#### RK4 method
### RK4 method

- Scheme:
$`X^n = X^{n+1} - \frac{dt}{6} \left( k_1 + 2 k_2 + 2 k_3 + k_4\right)`$
Expand All @@ -97,7 +94,7 @@ $`X^n = X^{n+1} - \frac{dt}{6} \left( k_1 + 2 k_2 + 2 k_3 + k_4\right)`$



### Advection domain
## Advection domain

There are two advection domains implemented:
- the physical domain: AdvectionPhysicalDomain;
Expand Down Expand Up @@ -146,7 +143,124 @@ and $`(J_{\mathcal{F}}J_{\mathcal{G}}^{-1})^{-1}`$ is well-defined. The details
**Remark 2:** if the mapping function is analytically invertible, it is less costly to advect in the physical domain.


## Unit tests

## Advection Field

In the studied equation, the advection field is given along the physical domain axis:
```math
\partial_t f + A_x \partial_x f + A_y \partial_y f = 0.
```

The BslAdvectionRP operator can take as input the advection field along the physical domain axis or the advection field along the logical domain axis,
```math
A = (A_x, A_y) \quad \text{or} \quad A = (A_r, A_\theta).
```

The advection field can be computed thanks to the AdvectionFieldFinder operator. This operator returns the advection field along the physical domain axes or the advection field along the logical domain axes (see [advection\_field\_rp](./../advection_field/README.md)).

* If the advection field is directly given along the physical domain axes, no treatment is needed in the BslAdvectionRP operator.

* If the advection field is given along the logical domain axes, then we need to compute the advection field along the physical domain axes to advect in the physical domain.

**In the guiding-center case**, the advection field is computed from the electric field,
```math
A = - E \wedge e_z = -\nabla \phi \wedge e_z.
```

In [the documentation for the advection field](./../advection_field/README.md), we show that
```math
\nabla_{xy} \phi = J D_{G}^{-1}\nabla_{r\theta} \phi,
```

with *J* the Jacobian matrix and the following diagonal matrix
```math
D_{G}
=
\begin{bmatrix}
\sqrt{g_{11}} & 0 \\
0 & \sqrt{g_{22}} \\
\end{bmatrix}
```

with the metric tensor $`G = J^TJ = [g_{ij}]_{ij}`$.

It gives the following relation for the electric field
```math
\begin{bmatrix}
E_x \\
E_y \\
\end{bmatrix}
=
J D_{G}^{-1}
\begin{bmatrix}
E_r \\
E_\theta \\
\end{bmatrix}
=
\begin{bmatrix}
\frac{j_{11}}{\sqrt{g_{11}}} & \frac{j_{12}}{\sqrt{g_{22}}} \\
\frac{j_{21}}{\sqrt{g_{11}}} & \frac{j_{22}}{\sqrt{g_{22}}} \\
\end{bmatrix}
\begin{bmatrix}
E_r \\
E_\theta \\
\end{bmatrix}.
```


We deduce that
```math
\begin{bmatrix}
A_x \\
A_y
\end{bmatrix}
=
\begin{bmatrix}
- Ey \\
E_x
\end{bmatrix}
=
\begin{bmatrix}
- \frac{j_{21}}{\sqrt{g_{11}}}E_r - \frac{j_{22}}{\sqrt{g_{22}}} E_\theta\\
\frac{j_{11}}{\sqrt{g_{11}}}E_r + \frac{j_{12}}{\sqrt{g_{22}}} E_\theta \\
\end{bmatrix}
=
\begin{bmatrix}
\frac{j_{22}}{\sqrt{g_{22}}} & - \frac{j_{21}}{\sqrt{g_{11}}} \\
- \frac{j_{12}}{\sqrt{g_{22}}} & \frac{j_{11}}{\sqrt{g_{11}}}
\end{bmatrix}
\begin{bmatrix}
- E_\theta \\
E_r
\end{bmatrix}
=
\det(JD_{G}^{-1}) ((JD_{G}^{-1})^{-1})^{T}
\begin{bmatrix}
- E_\theta \\
E_r
\end{bmatrix}
=
\det(J) (J^{-1})^{T} det(D_{G}^{-1}) D_G
\begin{bmatrix}
A_r \\
A_\theta
\end{bmatrix}.
```

So, from the advection field along the logical domain axis, we multiply by
```math
\det(J) det(D_{G}^{-1}) (J^{-1})^{T} D_G
=
\begin{bmatrix}
\frac{j_{22}}{\sqrt{g_{22}}} & - \frac{j_{21}}{\sqrt{g_{11}}} \\
- \frac{j_{12}}{\sqrt{g_{22}}} & \frac{j_{11}}{\sqrt{g_{11}}}
\end{bmatrix},
```

to get the advection field along the physical domain axis.


# Unit tests

The test of the advection operator are implemented in the `tests/geometryRTheta/advection_2d_rp/` folder
([advection\_2d\_rp](./../../../tests/geometryRTheta/advection_2d_rp/README.md)).
Expand Down Expand Up @@ -181,14 +295,14 @@ for $n = 1, 2, 4, 8, ...$.



## References
# References
[1] Edoardo Zoni, Yaman Güçlü. "Solving hyperbolic-elliptic problems on singular mapped
disk-like domains with the method of characteristics and spline finite elements".
([https://doi.org/10.1016/j.jcp.2019.108889](https://doi.org/10.1016/j.jcp.2019.108889).)
Journal of Computational Physics (2019).


## Contents
# Contents

This folder contains:
- advection\_domain.hpp : define the different advection domains (AdvectionDomain).
Expand Down
Loading

0 comments on commit dcdba00

Please sign in to comment.