|
| 1 | +## Langmuir_wave.py |
| 2 | +# Example of plasma oscillations of electrons |
| 3 | +import os, sys; |
| 4 | +sys.path.append(os.path.join(os.path.dirname(__file__), '..')) |
| 5 | +from jaxincell.plot import plot |
| 6 | +from jaxincell.simulation import simulation |
| 7 | +import jax.numpy as jnp |
| 8 | +from jax import block_until_ready |
| 9 | + |
| 10 | +input_parameters = { |
| 11 | +"length" : 1e-2, # dimensions of the simulation box in (x, y, z) |
| 12 | +"amplitude_perturbation_x" : 5e-4, # amplitude of sinusoidal perturbation in x |
| 13 | +"wavenumber_electrons": 8, # Wavenumber of sinusoidal electron density perturbation in x (factor of 2pi/length) |
| 14 | +"grid_points_per_Debye_length" : 5, # dx over Debye length |
| 15 | +"vth_electrons_over_c" : 0.05, # thermal velocity of electrons over speed of light |
| 16 | +"ion_temperature_over_electron_temperature": 1e-9, # Temperature of ions over temperature of electrons |
| 17 | +"timestep_over_spatialstep_times_c": 0.5, # dt * speed_of_light / dx |
| 18 | +"print_info" : True, # print information about the simulation |
| 19 | +} |
| 20 | + |
| 21 | +solver_parameters = { |
| 22 | + "field_solver" : 0, # Algorithm to solve E and B fields - 0: Curl_EB, 1: Gauss_1D_FFT, 2: Gauss_1D_Cartesian, 3: Poisson_1D_FFT, |
| 23 | + "number_grid_points" : 33, # Number of grid points |
| 24 | + "number_pseudoelectrons" : 3000, # Number of pseudoelectrons |
| 25 | + "total_steps" : 1000, # Total number of time steps |
| 26 | +} |
| 27 | + |
| 28 | +output = block_until_ready(simulation(input_parameters, **solver_parameters)) |
| 29 | + |
| 30 | +print(f"Dominant FFT frequency (f): {output['dominant_frequency']} Hz") |
| 31 | +print(f"Plasma frequency (w_p): {output['plasma_frequency']} Hz") |
| 32 | +print(f"Error: {jnp.abs(output['dominant_frequency'] - output['plasma_frequency']) / output['plasma_frequency'] * 100:.2f}%") |
| 33 | + |
| 34 | +plot(output) |
0 commit comments