Particle transfer to continuation simulation
For long geometries the simulation can be chopped in to two pieces. The first simulation can be higher resolution where it is needed, a plasma extraction for example and a following beam tube can be done as a continuation simulation in IBSimu or some other program.
Please note that the beam potential may have an effect on the particle velocities. You might want to assume symmetry (NEUMANN) on the exit boundary and take the particle coordinates at a plane before the exit boundary for maximum accuracy.
For taking the particles from a simulation and making a data file containing the particle data you can do the following:
// Write output file containing all particles ofstream fileOut( "particles_out.txt" ); // Do trajectory diagnostics at a selected plane TrajectoryDiagnosticData tdata; vectordiag; diag.push_back( DIAG_CURR ); diag.push_back( DIAG_MASS ); diag.push_back( DIAG_T ); diag.push_back( DIAG_X ); diag.push_back( DIAG_VX ); diag.push_back( DIAG_Y ); diag.push_back( DIAG_VY ); diag.push_back( DIAG_Z ); diag.push_back( DIAG_VZ ); pdb.trajectories_at_plane( tdata, AXIS_Z, 0.2, diag ); for( uint32_t b = 0; b < tdata.traj_size(); b++ ) { fileOut << setw(12) << tdata(b,0) << " " << setw(12) << tdata(b,1) << " " << setw(12) << tdata(b,2) << " " << setw(12) << tdata(b,3) << " " << setw(12) << tdata(b,4) << " " << setw(12) << tdata(b,5) << " " << setw(12) << tdata(b,6) << " " << setw(12) << tdata(b,7) << " " << setw(12) << tdata(b,8) << "\n"; } fileOut.close();
For defining a beam using the data file in IBSimu you can do something like this:
// Input particles
ReadAscii din( "particles_out", 9 );
cout << "Reading " << din.rows() << " particles\n";
// Go through all read particles
for( size_t i = 0; i < din.rows(); i++ ) {
double I = din[0][i];
double m = din[1][i];
double t = din[2][i];
double x = din[3][i];
double vx = din[4][i];
double y = din[5][i];
double vy = din[6][i];
double z = din[7][i];
double vz = din[8][i];
pdb.add_particle( I, 1.0, m/MASS_U, ParticleP3D(t,x,vx,y,vy,z,vz) );
}