diff --git a/FDTD/excitation.cpp b/FDTD/excitation.cpp index f095b53..4e1ba85 100644 --- a/FDTD/excitation.cpp +++ b/FDTD/excitation.cpp @@ -137,7 +137,7 @@ unsigned int Excitation::GetMaxExcitationTimestep() const { FDTD_FLOAT maxAmp=0; unsigned int maxStep=0; - for (unsigned int n=1; nmaxAmp) { @@ -152,7 +152,7 @@ void Excitation::CalcGaussianPulsExcitation(double f0, double fc, int nTS) { if (dT==0) return; - Length = (unsigned int)(2.0 * 9.0/(2.0*PI*fc) / dT); + Length = (unsigned int)ceil(2.0 * 9.0/(2.0*PI*fc) / dT); if (Length>(unsigned int)nTS) { cerr << "Operator::CalcGaussianPulsExcitation: Requested excitation pusle would be " << Length << " timesteps or " << Length * dT << " s long. Cutting to max number of timesteps!" << endl; @@ -160,13 +160,11 @@ void Excitation::CalcGaussianPulsExcitation(double f0, double fc, int nTS) } delete[] Signal_volt; delete[] Signal_curr; - Signal_volt = new FDTD_FLOAT[Length+1]; - Signal_curr = new FDTD_FLOAT[Length+1]; - Signal_volt[0]=0.0; - Signal_curr[0]=0.0; - for (unsigned int n=1; nVolt_delay[n]; exc_pos *= (exc_pos>0); exc_pos %= p; - exc_pos *= (exc_pos<=(int)length); + exc_pos *= (exc_pos<(int)length); ny = m_Op_Exc->Volt_dir[n]; pos[0]=m_Op_Exc->Volt_index[0][n]; pos[1]=m_Op_Exc->Volt_index[1][n]; @@ -71,7 +71,7 @@ void Engine_Ext_Excitation::Apply2Voltages() exc_pos = numTS - (int)m_Op_Exc->Volt_delay[n]; exc_pos *= (exc_pos>0); exc_pos %= p; - exc_pos *= (exc_pos<=(int)length); + exc_pos *= (exc_pos<(int)length); ny = m_Op_Exc->Volt_dir[n]; pos[0]=m_Op_Exc->Volt_index[0][n]; pos[1]=m_Op_Exc->Volt_index[1][n]; @@ -87,7 +87,7 @@ void Engine_Ext_Excitation::Apply2Voltages() exc_pos = numTS - (int)m_Op_Exc->Volt_delay[n]; exc_pos *= (exc_pos>0); exc_pos %= p; - exc_pos *= (exc_pos<=(int)length); + exc_pos *= (exc_pos<(int)length); ny = m_Op_Exc->Volt_dir[n]; pos[0]=m_Op_Exc->Volt_index[0][n]; pos[1]=m_Op_Exc->Volt_index[1][n]; @@ -124,7 +124,7 @@ void Engine_Ext_Excitation::Apply2Current() exc_pos = numTS - (int)m_Op_Exc->Curr_delay[n]; exc_pos *= (exc_pos>0); exc_pos %= p; - exc_pos *= (exc_pos<=(int)length); + exc_pos *= (exc_pos<(int)length); ny = m_Op_Exc->Curr_dir[n]; pos[0]=m_Op_Exc->Curr_index[0][n]; pos[1]=m_Op_Exc->Curr_index[1][n]; @@ -141,7 +141,7 @@ void Engine_Ext_Excitation::Apply2Current() exc_pos = numTS - (int)m_Op_Exc->Curr_delay[n]; exc_pos *= (exc_pos>0); exc_pos %= p; - exc_pos *= (exc_pos<=(int)length); + exc_pos *= (exc_pos<(int)length); ny = m_Op_Exc->Curr_dir[n]; pos[0]=m_Op_Exc->Curr_index[0][n]; pos[1]=m_Op_Exc->Curr_index[1][n]; @@ -157,7 +157,7 @@ void Engine_Ext_Excitation::Apply2Current() exc_pos = numTS - (int)m_Op_Exc->Curr_delay[n]; exc_pos *= (exc_pos>0); exc_pos %= p; - exc_pos *= (exc_pos<=(int)length); + exc_pos *= (exc_pos<(int)length); ny = m_Op_Exc->Curr_dir[n]; pos[0]=m_Op_Exc->Curr_index[0][n]; pos[1]=m_Op_Exc->Curr_index[1][n]; diff --git a/FDTD/extensions/engine_ext_tfsf.cpp b/FDTD/extensions/engine_ext_tfsf.cpp index cd3b107..9942656 100644 --- a/FDTD/extensions/engine_ext_tfsf.cpp +++ b/FDTD/extensions/engine_ext_tfsf.cpp @@ -44,7 +44,7 @@ void Engine_Ext_TFSF::DoPostVoltageUpdates() { if ( numTS < n ) m_DelayLookup[n]=0; - else if ((numTS-n > length) && (p==0)) + else if ((numTS-n >= length) && (p==0)) m_DelayLookup[n]=0; else m_DelayLookup[n] = numTS - n; @@ -134,7 +134,7 @@ void Engine_Ext_TFSF::DoPostCurrentUpdates() { if ( numTS < n ) m_DelayLookup[n]=0; - else if ((numTS-n > length) && (p==0)) + else if ((numTS-n >= length) && (p==0)) m_DelayLookup[n]=0; else m_DelayLookup[n] = numTS - n;