Skip to content

Commit

Permalink
Bug fix: revert logic of IonizationFactory to the earlier one, move s…
Browse files Browse the repository at this point in the history
…ome checks to separate methods
  • Loading branch information
GianlucaOberreit committed Aug 29, 2024
1 parent 4e7909d commit ac64c96
Showing 1 changed file with 43 additions and 17 deletions.
60 changes: 43 additions & 17 deletions src/Ionization/IonizationFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 &params) {
if ( params.Laser_Envelope_model ) {
ERROR( "The ionization model for species interacting with envelope is tunnel_envelope_averaged" );
}
}
};

#endif

0 comments on commit ac64c96

Please sign in to comment.