Giter VIP home page Giter VIP logo

test_particle's Introduction

Test particle simulation

Test particle code to study particle transport or energization. The code is parallelized using MPI and OpenMP, and it use HDF5 for output.

Compile

  1. You need a MPI library and parallel HDF5.
  2. You may need to change some variables in Makfile, including CC, LD, and HDF5_ROOT.

Then, simply make in the root directory.

Run the code

  1. Copy config_files/init.dat and config_files/test_particle.sh into the directory that you are going to run the code. And you need to change init.dat and test_particle.sh. The variables in the files should be self-explained.
    • The included test_particle.sh is designed for using the fields generated by 3D VPIC simulations. You may have to write some code and scripts to load the fields from your own simulations.
  2. You can run the code by ./test_particle.sh.
  3. In default, the code generates four files.
    • diff_coeffs.dat (ASCII): diffusion coefficients. Please check diagnostics.c for details.
    • espectrum.dat (ASCII): energy spectrum. The first row is particle energy bins. The rest rows are spectrum at a series of time frames.
    • particle_diagnostics.h5 (HDF5): particle trajectories.
    • particles_fields_init.h5: initial particle information, including particle position, velocity, time, charge/mass, electric field, and magnetic field.

Plot

You can use the provided Python scripts to plot the data.

  1. Diffusion coefficients
python reconnection_analysis.py --run_name $run_name --run_dir $run_dir \
       --tinterval $tinterval --tframe $tframe --diff_coeff --ptl_vel 0.7

where you have to define the simulation's parameters. For multiple injection velocity, add --multi_vel flag.

  1. Energy spectrum: change --diff_coeff to plot_spectrum in the above script.
  2. Particle trajectory:
    • particle_diagnostics.h5 saves each particle information in a dataset. In order to read the data using ParaView + H5Part, we need to transfer the HDF5 file to a H5Part file using
    python reconnection_analysis.py --run_name $run_name --run_dir $run_dir \
           --tinterval $tinterval --tframe $tframe --tran_hdf5 --ptl_vel 0.7
    Then, we can load the generated file into ParaView and plot all particles at a single time step. You can generate time series be selecting one specific particles using ParaView's selection tools, but the process could be tedious. You's better write a python script to do that.
    • We can also generate piecewise trajectories for a single particle, so have a rough idea of the trajectory curve. It uses pyetvk to generate a single .vtu file for each time step.
    python reconnection_analysis.py --run_name $run_name --run_dir $run_dir \
           --tinterval $tinterval --tframe $tframe --piecewise_traj --ptl_vel 0.7
    You may also need to specify --iptl and --tint to get a specific trajectory and the number of steps before and after current step. Then, you can load these .vtu files into ParaView to show piecewise trajectories. You can use Paraview's ProgrammableFilter to generate vtkPolyData to make the trajectories curves. The ProgrammableFilter is given in vtu_vtkPolyData.py. Then, you can use the tube filter to make the trajectory look even better.

test_particle's People

Contributors

xiaocanli avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.