#include "epot_bicgstabsolver.hpp" #include "particledatabase.hpp" #include "geometry.hpp" #include "func_solid.hpp" #include "epot_efield.hpp" #include "meshvectorfield.hpp" #include "ibsimu.hpp" #include "error.hpp" #include "particlediagplotter.hpp" #include "geomplotter.hpp" #include "config.h" #ifdef GTK3 #include "gtkplotter.hpp" #endif const double Te = 5.0; const double Up = 5.0; bool solid1( double x, double y, double z ) { return( x <= 0.00187 && y >= 0.00054 && y >= 2.28*x - 0.0010 && (x >= 0.00054 || y >= 0.0015) ); } bool solid2( double x, double y, double z ) { return( x >= 0.0095 && y >= 0.0023333 && y >= 0.01283 - x ); } void simu( int *argc, char ***argv ) { Geometry geom( MODE_CYL, Int3D(241,141,1), Vec3D(0,0,0), 0.00005 ); Solid *s1 = new FuncSolid( solid1 ); geom.set_solid( 7, s1 ); Solid *s2 = new FuncSolid( solid2 ); geom.set_solid( 8, s2 ); geom.set_boundary( 1, Bound(BOUND_NEUMANN, 0.0 ) ); geom.set_boundary( 2, Bound(BOUND_DIRICHLET, -12.0e3) ); geom.set_boundary( 3, Bound(BOUND_NEUMANN, 0.0) ); geom.set_boundary( 4, Bound(BOUND_NEUMANN, 0.0) ); geom.set_boundary( 7, Bound(BOUND_DIRICHLET, 0.0) ); geom.set_boundary( 8, Bound(BOUND_DIRICHLET, -12.0e3) ); geom.build_mesh(); EpotBiCGSTABSolver solver( geom ); InitialPlasma initp( AXIS_X, 0.55e-3 ); solver.set_initial_plasma( 5.0, &initp ); EpotField epot( geom ); MeshScalarField scharge( geom ); MeshVectorField bfield; EpotEfield efield( epot ); field_extrpl_e efldextrpl[6] = { FIELD_EXTRAPOLATE, FIELD_EXTRAPOLATE, FIELD_SYMMETRIC_POTENTIAL, FIELD_EXTRAPOLATE, FIELD_EXTRAPOLATE, FIELD_EXTRAPOLATE }; efield.set_extrapolation( efldextrpl ); ParticleDataBaseCyl pdb( geom ); bool pmirror[6] = { false, false, true, false, false, false }; pdb.set_mirror( pmirror ); for( size_t i = 0; i < 15; i++ ) { if( i == 1 ) { double rhoe = pdb.get_rhosum(); solver.set_pexp_plasma( -rhoe, Te, Up ); } solver.solve( epot, scharge ); efield.recalculate(); pdb.clear(); pdb.add_2d_beam_with_energy( 15000, 600.0, 1.0, 4.0, 5.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.0015 ); pdb.iterate_trajectories( scharge, efield, bfield ); } #ifdef GTK3 GTKPlotter plotter( argc, argv ); plotter.set_geometry( &geom ); plotter.set_epot( &epot ); plotter.set_scharge( &scharge ); plotter.set_particledatabase( &pdb ); plotter.new_geometry_plot_window(); plotter.run(); #endif } int main( int argc, char **argv ) { try { ibsimu.set_message_threshold( MSG_VERBOSE, 1 ); ibsimu.set_thread_count( 4 ); simu( &argc, &argv ); } catch ( Error e ) { e.print_error_message( ibsimu.message( 0 ) ); exit( 1 ); } return( 0 ); }