Coder Social home page Coder Social logo

1d_p-i-c's Introduction

1 dimensional particle-in-cell code

Files description

  • parameters.py - simulation & plasma parameters

  • generation.py - various function to generate plasma

  • cycle.py - basic [backwards]weighting and solution functions

  • main.py - the main part containing the whole p-i-c cycle and data export

  • plotter.py - for creating animation from data exported to .dat files

  • helpers.py - progress-bar and timing functions

Simulation

The program can be started by calling python main.py. Make sure to modify output paths in main.py and input in parameters.py:

NAME =input_value_name

This NAME determines what primary configuration is used:

  • ’plasma_fluc’ - simple plasma fluctuations (see video)
  • ’two-stream’ - two-stream instability (uniform distribution) (see video)
  • ’two-stream_r’ - two-stream instability (random distribution) (see video)
  • ’four-stream’ - "four-stream" instability (kind of) (see video)
  • ’beam_instability’ - beam instability (see video)

Plotting

Plotter works distinctly by calling python plotter.py. To simply view the animation comment out anim.save(…) leaving plt.show(). To save the animation, make sure to put ffmpeg codecs from here to your /usr/local/bin/ directory (necessary for OS X).

Experimenting with various inputs

Feel free to create your own plasma generation functions. Add the NAME parameter for it in parameters.py and add the elif case in main.py.

The only thing you need to keep in mind, is to keep the overall charge density neutral. You can check that by doing

numpy.sum(density(particles)[:-1])

[:-1] here is because of the periodic boundary conditions and density[NODES - 1] equals to density[0].

Particles can be movable, i.e., particle.mv = True, or permanently nailed in place, particle.mv = False.

Particle class

This class contains the info about particles.

It accepts:

  • pos: position
  • vel: velocity
  • omegaP: plasma frequency
  • QoverM: charge-to-mass ratio
  • move: True if particle is movable, False if it’s not

It contains:

  • particle.x and particle.v: [accepts float] logical position and velocity of the particle

  • particle.qm: [accepts float] charge/mass ratio for the particle

  • particle.q: particle charge determined by the equation

    self.q = omega_p**2 * (1 / qm) * eps_0 * (L / N)
    • omega_p is the given plasma frequency
    • eps_0 is the vacuum permittivity (set to be 1)
    • L / N is the number density of particle specie
  • particle.mv: [accepts bool] the particle is either movable or not

Further reading

  • Birdsall, C. K., & Langdon, A. B., 1991, Plasma Physics via Computer Simulation, The Adam Hilger Series on Plasma Physics, edited by C. Birdsall & A. Langdon. Adam Hilger, Bristol, England (ISBN: 0-07-005371-5)
  • Hockney, R. W., & Eastwood, J. W., 1988, Computer Simulation Using Particles, Bristol: Hilger (ISBN: 978-0852743928)

1d_p-i-c's People

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.