Graph Framework
Loading...
Searching...
No Matches
physics_test.cpp File Reference

Tests for math nodes. More...

#include <cassert>
#include <chrono>
#include <random>
#include "../graph_framework/solver.hpp"

Functions

template<jit::float_scalar T>
void test_constant ()
 Constant Test.
 
template<solver::method SOLVER>
void test_bohm_gross (const typename SOLVER::base tolarance)
 Bohm-Gross Test.
 
template<solver::method SOLVER>
void test_light_wave (const typename SOLVER::base tolarance)
 Light wave Test.
 
template<jit::float_scalar T>
void test_acoustic_wave (const T tolarance)
 Ion acoustic wave Test.
 
template<jit::float_scalar T>
void test_o_mode_wave ()
 O Mode Test.
 
template<jit::float_scalar T>
void test_cold_plasma_cutoffs ()
 Cold Plasma Dispersion Relation Right Cutoff Frequency.
 
template<jit::float_scalar T>
void test_reflection (const T tolarance, const T n0, const T x0, const T kx0)
 Reflection test.
 
template<jit::float_scalar T>
void test_efit ()
 Efit equilibrium test.
 
template<jit::float_scalar T>
void run_tests (const T tolarance)
 Run tests with a specified backend.
 
int main (int argc, const char *argv[])
 Main program of the test.
 

Detailed Description

Tests for math nodes.

Function Documentation

◆ main()

int main ( int  argc,
const char *  argv[] 
)

Main program of the test.

Parameters
[in]argcNumber of commandline arguments.
[in]argvArray of commandline arguments.

◆ run_tests()

template<jit::float_scalar T>
void run_tests ( const T  tolarance)

Run tests with a specified backend.

Template Parameters
TBase type of the calculation.
Parameters
[in]tolaranceTolarance to solver the dispersion function to.

◆ test_acoustic_wave()

template<jit::float_scalar T>
void test_acoustic_wave ( const T  tolarance)

Ion acoustic wave Test.

In the ion-wave dispersion relation, the group velocity should be.

vg = vs^2*k/⍵ (1)

Where vs is the sound speed.

vs = sqrt((kb*Te - ɣ*kb*ti)/mi) (2)

The wave number is constant in time.

k(t) = 0 (3)

The slope of the wave trajectory is vs

dx/dt = vs^2 (4)

Template Parameters
TBase type of the calculation.
Parameters
[in]tolaranceTolarance to solver the dispersion function to.

◆ test_bohm_gross()

template<solver::method SOLVER>
void test_bohm_gross ( const typename SOLVER::base  tolarance)

Bohm-Gross Test.

In the bohm-gross dispersion relation, the group velocity should be.

vg = 3/2*vth^2*k/⍵ (1)

Where vth is the thermal velocity.

vth = sqrt(2*kb*T/m) (2)

The wave number varies with time.

k(t) = -⍵pe'(x)/(2⍵)*t + k0 (3)

Where ⍵pe is the plasma frequency.

⍵pe2 = q^2*n(x))/(ϵ0*m) (4)

For a linear gradient in the density ⍵pe2'(x) is a constant.

⍵pe2' = ne0*q^2*0.1/(ϵ0*m) (5)

k0 must be a solution of the dispersion relation.

k0 = sqrt(3/2(⍵^2 - ⍵pe^2)/vth^2) (6)

Putting equation 3 into 1 yields the group velocity as a function of time.

vg(t) = -3/2*vth^2/⍵*⍵pe'(x)/(2⍵)*t + 3/2*vth^2/⍵*k0 (7)

This expression can be integrated to find a parabolic ray trajectory.

x(t) = -3/8*vth^2/⍵*⍵pe'(x)/⍵*t^2 + 3/2*vth^2/⍵*k0*t + x0 (8)

B = 0 or k || B

Template Parameters
SOLVERClass of solver to use.
Parameters
[in]tolaranceTolarance to solver the dispersion function to.

◆ test_cold_plasma_cutoffs()

template<jit::float_scalar T>
void test_cold_plasma_cutoffs ( )

Cold Plasma Dispersion Relation Right Cutoff Frequency.

There are two branches on the dispersion relation. The O-Mode branch can propagate past the right cuttoff and the upper hybrid resonance but is cut off at the Plasma frequency. The x-mode is cut off by the right cutoff for frequencies above and trapped between the left and cutoff and the upper hybird resonance.

Template Parameters
TBase type of the calculation.

◆ test_constant()

template<jit::float_scalar T>
void test_constant ( )

Constant Test.

A wave in no medium with a constant phase velocity should propagate such that

k.x - wt = Constant

Template Parameters
TBase type of the calculation.

◆ test_efit()

template<jit::float_scalar T>
void test_efit ( )

Efit equilibrium test.

Template Parameters
TBase type of the calculation.

◆ test_light_wave()

template<solver::method SOLVER>
void test_light_wave ( const typename SOLVER::base  tolarance)

Light wave Test.

In the bohm-gross dispersion relation, the group velocity should be.

vg = c^2*k/⍵ (1)

Where c is the speed of light. The wave number varies with time.

k(t) = -⍵pe'(x)/(2⍵)*t + k0 (3)

Where ⍵pe is the plasma frequency.

⍵pe2 = q^2*n(x))/(ϵ0*m) (4)

For a linear gradient in the density ⍵pe2'(x) is a constant.

⍵pe2' = ne0*q^2*0.1/(ϵ0*m) (5)

k0 must be a solution of the dispersion relation.

k0 = sqrt((⍵^2 - ⍵pe^2)/c^2) (6)

Putting equation 3 into 1 yields the group velocity as a function of time.

vg(t) = -c^2/⍵*⍵pe'(x)/(2⍵)*t + c^2/⍵*k0 (7)

This expression can be integrated to find a parabolic ray trajectory.

x(t) = -1/4*c^2/⍵*⍵pe'(x)/⍵*t^2 + c^2/⍵*k0*t + x0 (8)

B = 0

Template Parameters
SOLVERClass of solver to use.
Parameters
[in]tolaranceTolarance to solver the dispersion function to.

◆ test_o_mode_wave()

template<jit::float_scalar T>
void test_o_mode_wave ( )

O Mode Test.

For a linear density gradient, the O-Mode cut off should be located at

1 - ⍵pe^2(x)/⍵^2 = 0 (1)

⍵^2 - 1 = ⍵pe^2 (2)

The plasma frequency is defined as

⍵pe^2 = ne0*q^2/(ϵ0*m)*(0.1*x + 1) (3)

Putting equation 3 into 2 yields

⍵^2 - 1 = ne0*q^2/(ϵ0*m)*(0.1*x + 1) (4)

Solving for x

(⍵^2 - 1 - ne0*q^2/(ϵ0*m))/(ne0*q^2/(ϵ0*m)*0.1) = x (5)

Template Parameters
TBase type of the calculation.

◆ test_reflection()

template<jit::float_scalar T>
void test_reflection ( const T  tolarance,
const T  n0,
const T  x0,
const T  kx0 
)

Reflection test.

Given a wave frequency, a wave with zero k will not propagate.

Template Parameters
TBase type of the calculation.
Parameters
[in]tolaranceTolarance to solver the dispersion function to.
[in]n0Starting nz value.
[in]x0Starting x guess.
[in]kx0Starting kx guess.