Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Readin from HiPACE-C files improved + conversion script #315

Merged
merged 4 commits into from
Jan 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/particles/BeamParticleContainer.H
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ public:
bool coordinates_specified,
amrex::Array<std::string, AMREX_SPACEDIM> file_coordinates_xyz,
const amrex::Geometry& geom,
const amrex::Real n_0);
amrex::Real n_0);

/** Checks the input file first to determine its Datatype*/
template<typename input_type>
void InitBeamFromFile (std::string input_file,
bool coordinates_specified,
amrex::Array<std::string, AMREX_SPACEDIM> file_coordinates_xyz,
const amrex::Geometry& geom,
const amrex::Real n_0);
amrex::Real n_0);
#endif

#ifdef AMREX_USE_MPI
Expand Down
9 changes: 4 additions & 5 deletions src/particles/BeamParticleContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ BeamParticleContainer::ReadParameters ()
pp.query("dx_per_dzeta", m_dx_per_dzeta);
pp.query("dy_per_dzeta", m_dy_per_dzeta);
pp.query("do_z_push", m_do_z_push);
if (m_injection_type == "fixed_ppc"){
if (m_injection_type == "fixed_ppc" || m_injection_type == "from_file"){
AMREX_ALWAYS_ASSERT_WITH_MESSAGE( (m_dx_per_dzeta == 0.) && (m_dy_per_dzeta == 0.),
"Tilted beams are not yet implemented for fixed ppc beams");
"Tilted beams are not yet implemented for fixed ppc beams or beams from file");
}
}

Expand Down Expand Up @@ -89,9 +89,8 @@ BeamParticleContainer::InitData (const amrex::Geometry& geom)
bool coordinates_specified = pp.query("file_coordinates_xyz", m_file_coordinates_xyz);
bool n_0_specified = pp.query("plasma_density", m_plasma_density);

if(Hipace::m_normalized_units) {
AMREX_ALWAYS_ASSERT_WITH_MESSAGE(n_0_specified, "Please specify the plasma density of "
"the external beam to use it with normalized units with beam.plasma_density");
if(!n_0_specified) {
m_plasma_density = 0;
}

InitBeamFromFileHelper(m_input_file, coordinates_specified, m_file_coordinates_xyz, geom,
Expand Down
16 changes: 13 additions & 3 deletions src/particles/BeamParticleContainerInit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ InitBeamFromFileHelper (std::string input_file,
bool coordinates_specified,
amrex::Array<std::string, AMREX_SPACEDIM> file_coordinates_xyz,
const amrex::Geometry& geom,
const amrex::Real n_0)
amrex::Real n_0)
{
HIPACE_PROFILE("BeamParticleContainer::InitParticles");

Expand Down Expand Up @@ -329,7 +329,7 @@ InitBeamFromFile (std::string input_file,
bool coordinates_specified,
amrex::Array<std::string, AMREX_SPACEDIM> file_coordinates_xyz,
const amrex::Geometry& geom,
const amrex::Real n_0)
amrex::Real n_0)
{
HIPACE_PROFILE("BeamParticleContainer::InitParticles");

Expand Down Expand Up @@ -455,7 +455,17 @@ InitBeamFromFile (std::string input_file,
const PhysConst phys_const_SI = make_constants_SI();
input_type si_to_norm_pos = (input_type)( 1. );
input_type si_to_norm_charge = (input_type)( phys_const_SI.q_e );

if(Hipace::m_normalized_units) {
if(n_0 == 0) {
if(electrons.containsAttribute("Hipace++_Plasma_Density")) {
n_0 = electrons.getAttribute("Hipace++_Plasma_Density").get<double>();
}
else {
amrex::Abort("Please specify the plasma density of the external beam "
"to use it with normalized units with beam.plasma_density");
}
}
auto dx = geom.CellSizeArray();
double omega_p = (double)phys_const_SI.q_e * sqrt( (double)n_0 /
( (double)phys_const_SI.ep0 * (double)phys_const_SI.m_e ) );
Expand Down Expand Up @@ -484,7 +494,7 @@ InitBeamFromFile (std::string input_file,
input_type file_e_m = q_q_data.get()[0] * unit_qq / (q_q_data.get()[0] * unit_mm);
if( std::abs(file_e_m - ( phys_const_SI.q_e / phys_const_SI.m_e ) ) > 1e9) {
amrex::Abort("Charge / Mass of Beam Particle from file "
"dose not match electrons (1.7588e11)\n");
"does not match electrons (1.7588e11)\n");
}
}
else {
Expand Down
Loading