Giter VIP home page Giter VIP logo

ef_python's Introduction

Ef is a software for simulation of charged particles dynamics. It's primary areas of application are accelerator science and plasma physics. Below are several examples of the simulations that can be done with this program:


Single particle in uniform magnetic field;       Widening of a ribbon beam during the propagation



Ribbon beam in uniform magnetic field



Potential of electron beam inside conducting tube;       Volt-Ampere characteristic of a planar diode

Ef focuses on nonrelativistic energies. Particular emphasis is placed on low-energy beams, such that can be found in ion sources and electron guns. A motivation behind the program, the scope and the general goals are discussed here.

Particles dynamics is traced under action of external electromagnetic fields. Particle self-interaction is taken into account with particle-in-cell method. Detailed description of the mathematical model can be found here.

Attention is given to integration with CAD software to allow for simulation of complex real-life experimental setups. An experimental plugin for FreeCAD exists.

Ef is a free software -- it's source code is open and avaible for modification and redistribution. C++ (this one) and Python versions are available. While Python version is easy to install and experiment with, it is reccomended to use C++ version for large-scale simulations.

Current features are described in detail in appropriate wiki sections, as well as installation procedure. Some usage examples are also given.

ef_python's People

Contributors

dumbman avatar fizmat avatar noooway avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ef_python's Issues

Визуализация для jupyter

Может файл для визуализации в jupyterе внести в основную программу? А то у меня он дорабатывается. И в разных папках он разных версий получается. Или папку отдельную сделать?

Publish package in pypi when ready

  • Wait until code is more finished
  • Finalize package name selection
    • Is ef is too short?
    • Is ef_python informative and readable?
  • Update README
  • Check and update setup.py

Migrate code to numpy

Migration to numpy from lists and Vec3d classes should accelerate the code.
Besides, pyCUDA and pyOpenCL libraries can transfer numpy arrays to GPU semiautomatically.

Частицы не чувствуют Inner region

Я сделал пример где сравниваются пучки с электродами и внешним полем. Нашел два недостатка:

  1. Пучок пролетает сквозь анод. В первом расчете
  2. После запуска ячейки с командой выполнения программы. Она все посчитала. Все h5 файлы есть в папке, но ячейка почему то в работе знак [*] не исчезает . Приходится останавливать kernel. И продолжать строить графики уже после остановки.

Transfer examples to Jupyter notebooks

Finish migration of examples to Jupyter notebooks.
Some examples are ready; update wiki pages accordingly.
In the wiki leave only problem statement and short results summary; move details into notebooks.
For each example provide:

  • a link to Jupyter notebook in the repo
  • a link to Google Colab version
  • a command to run console scripts

Current status:
* Single Particle in Free Space
* Single Particle In Uniform Magnetic Field
* Single Particle In Uniform Electric Field
* Ribbon Beam Contour
* Contour of Ribbon Beam In Uniform Magnetic Field
* Axially Symmetric Beam Contour
* Contour of Axially Symmetric Beam In Uniform Magnetic Field
* Potential well of cylindrical beam in tube
* Conducting Sphere Potential
* Child-Langmuir Law for Planar Diode
* Maxwell-Boltzmann Distribution Test
* Off-Axis Ion Extraction
* Acceleration of Ions by Collisions with Electrons

не запускается расчет из h5 файла

Хотел по образу и подобию сделать чтение из h5 файла как у тебя. Но методы например из Spatial_mesh исполнялись с ошибкой. Всю ночь бился. Только сегодня подумал проверить как у тебя чтение работает. И не смог запустить

ab@ab-work:~/ef_python/examples/single_particle_in_magnetic_field$ python3 ../../main.py long_simulation_0000000.h5
Traceback (most recent call last):
File "../../main.py", line 73, in
main()
File "../../main.py", line 18, in main
dom, continue_from_h5 = construct_domain( config_or_h5_file )
File "../../main.py", line 36, in construct_domain
extract_filename_prefix_and_suffix_from_h5filename( config_or_h5_file )
File "../../main.py", line 60, in extract_filename_prefix_and_suffix_from_h5filename
if len( match.group ) == 1:
TypeError: object of type 'builtin_function_or_method' has no len()

Define several functions to visulize computed results

There are several typical tasks for visualization, e.g:

  • Plot particles positions in 3d
  • Plot 2d projection of particles positions
  • Plot trajectories of particles with given id
    etc

Define such functions to quickly preview results of simulation.

Test of Example: Single Particle In Uniform Electric Field

After calculation the terminal shows:

Saving 3D trajectory plot to "3d.png"
Saving 2D trajectory projection plots to "2d.png"
Saving kinetic energy comparison plot to "kin_en.png"

But at fact the files were not created in the folder of the example.

Define common geometric primitives classes; use them in particles sources and inner regions

Currently there is some code duplication between InnerRegions and ParticleSources
concerning their geometric shape. It seems natural to define separate classes for geometric primitives and utilize them.

The work has been started in https://github.com/epicf/ef_python/tree/geometric-primitives branch.
For each primitive it is necessary to provide at least two methods: a way to check if a point with given coordinates is inside this primitive (to remove particles after collision) and a way to generate a point inside it (for sources).

Besides, annoying problem is to read primitive definitions from config.
There is no natural support for subsections in INI-files so it is necessary to write geometric primitives as strings and then parse those string in class constructors. It has been implemented (though not tested yet), but probably there is a better solution.

Current status:
It is necessary to test initialization of classes from text string. And it is necessary to replace current geometry-related code in inner regions and sources with this new classes. Then it would be necessary to update and test examples.

Migrate from CGS to SI units

SI units seem more convenient for current applications.
Some parts of the code and examples have to be transferred.

ConeAlongZ problem for Pierce gun

Пример с пушкой пирса. Я задал начальный внутренний радиус конуса катода 0. Но видимо при работе функции "найти координату в области" получилось что несколько ячеек вблизи нуля не являются частью электрода. Частицы пролетают сквозь конус в обратном направлении.

[TimeGrid]
total_time = 3.5e-10
time_save_step = 3.5e-12
time_step_size = 3.5e-12

[SpatialMesh]
grid_x_size = 1.4
grid_x_step = 0.035
grid_y_size = 1.4
grid_y_step = 0.035
grid_z_size = 0.7
grid_z_step = 0.0175

[ParticleSourceCylinder.emit_single_particle]
cylinder_axis_start_x = 0.7
cylinder_axis_start_y = 0.7
cylinder_axis_start_z = 0.2
cylinder_axis_end_x = 0.7
cylinder_axis_end_y = 0.7
cylinder_axis_end_z = 0.21
cylinder_radius = 0.06
initial_number_of_particles = 100
particles_to_generate_each_step = 100
mean_momentum_x = 0.0
mean_momentum_y = 0.0
mean_momentum_z = 1.225e-15
temperature = 0.0
charge = -1.049e-05
mass = 2.142e-23

[InnerRegionConeAlongZ.Cone_Catode]
cone_axis_x = 0.7
cone_axis_y = 0.7
cone_axis_start_z = 0.2
cone_axis_end_z = 0.35
cone_start_inner_radius = 0.0
cone_start_outer_radius = 0.275
cone_end_inner_radius = 0.587
cone_end_outer_radius = 0.6
potential = -3.3

[InnerRegionConeAlongZ.Cone_Anode]
cone_axis_x = 0.7
cone_axis_y = 0.7
cone_axis_start_z = 0.52
cone_axis_end_z = 0.67
cone_start_inner_radius = 0.0
cone_start_outer_radius = 0.275
cone_end_inner_radius = 0.0
cone_end_outer_radius = 0.6
potential = 0

[OutputFilename]
output_filename_prefix = pierce_
output_filename_suffix = .h5

[BoundaryConditions]
boundary_phi_right = 0.0
boundary_phi_left = 0.0
boundary_phi_bottom = 0.0
boundary_phi_top = 0.0
boundary_phi_near = 0.0
boundary_phi_far = 0.0

[ParticleInteractionModel]
particle_interaction_model = PIC

Basic testing

It is necessary to make sure that examples run and produce reasonable results after code updates.
While it is not obvious how to test results, it should be possible to test at least start, restart and output files automatically.

ветка cone

В файле InnerRegionsManager.py в inite 52 строчка

        elif InnerRegionConeAlongZ.is_cone_region(sec_name):
            new_obj.regions.append(
                InnerRegionTube.init_from_config(conf,
                                                 conf[sec_name],
                                                 sec_name,
                                                 spat_mesh))

В cone трубка создается получается

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.