diff --git a/src/Ionization/IonizationFactory.h b/src/Ionization/IonizationFactory.h index 0fe22fd6b..597eb14af 100644 --- a/src/Ionization/IonizationFactory.h +++ b/src/Ionization/IonizationFactory.h @@ -18,36 +18,62 @@ class IonizationFactory Ionization *Ionize = NULL; std::string model = species->ionization_model_; - if (species->max_charge_ > (int)species->atomic_number_) { - ERROR("Charge > atomic_number for species " << species->name_); - } - if (species->particles->is_test) { - ERROR("Cannot ionize test species " << species->name_); - } + if( model == "tunnel" ) { + checkMaxCharge(species); + checkNotLaserEnvelopeModel(params); + Ionize = new IonizationTunnel<0>( params, species ); // The original model included in Smilei + + } else if( model == "tunnel_envelope_averaged" ) { + checkMaxCharge(species); + checkTestParticle(species); + if ( !params.Laser_Envelope_model ) { + ERROR( "The ionization model tunnel_envelope_averaged needs a laser envelope"); + } + + Ionize = new IonizationTunnelEnvelopeAveraged( params, species ); - if (model == "tunnel_envelope_averaged") { - if (!params.Laser_Envelope_model) { - ERROR("The ionization model tunnel_envelope_averaged needs a laser envelope"); + } else if( model == "from_rate" ) { + if ( species->max_charge_ > ( int ) species->maximum_charge_state_ ) { + ERROR( "For species '" << species->name_ << ": charge > maximum_charge_state" ); } - Ionize = new IonizationTunnelEnvelopeAveraged(params, species); - } else if (params.Laser_Envelope_model) { - ERROR("The ionization model for species interacting with envelope is tunnel_envelope_averaged"); - } - if (model == "from_rate") { - Ionize = new IonizationFromRate(params, species); - } else if (model == "tunnel") { - Ionize = new IonizationTunnel<0>(params, species); // Tunnel, the original included in Smilei + Ionize = new IonizationFromRate( params, species ); + } else if (model == "tunnel_full_PPT") { + checkMaxCharge(species); + checkNotLaserEnvelopeModel(params); Ionize = new IonizationTunnel<1>(params, species); // FullPPT } else if (model == "tunnel_TL") { + checkMaxCharge(species); + checkNotLaserEnvelopeModel(params); Ionize = new IonizationTunnel<2>(params, species); // Tong&Ling } else if (model == "tunnel_BSI") { + checkMaxCharge(species); + checkNotLaserEnvelopeModel(params); Ionize = new IonizationTunnel<3>(params, species); // BSI } return Ionize; } + + private: + inline static void checkMaxCharge(const Species *species) { + if ( species->max_charge_ > ( int )species->atomic_number_ ) { + ERROR( "Charge > atomic_number for species " << species->name_ ); + } + } + + inline static void checkTestParticle(const Species *species) { + if( species->particles->is_test ) { + ERROR( "Cannot ionize test species " << species->name_ ); + } + } + + inline static void checkNotLaserEnvelopeModel(const Params ¶ms) { + if ( params.Laser_Envelope_model ) { + ERROR( "The ionization model for species interacting with envelope is tunnel_envelope_averaged" ); + } + } }; #endif