excitation: store only 2 periods of periodic excitations

Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
pull/13/head
Thorsten Liebig 2015-09-03 22:53:31 +02:00
parent b2f5ab3c6b
commit 9c80672855
4 changed files with 37 additions and 9 deletions

View File

@ -251,8 +251,8 @@ void Excitation::CalcSinusExcitation(double f0, int nTS)
if (dT==0) return; if (dT==0) return;
if (nTS<=0) return; if (nTS<=0) return;
Length = (unsigned int)(nTS); Length = (unsigned int)(2.0/f0/dT);
// cerr << "Operator::CalcSinusExcitation: Length of the excite signal: " << ExciteLength << " timesteps" << endl; //cerr << "Operator::CalcSinusExcitation: Length of the excite signal: " << Length << " timesteps " << Length*dT << "s" << endl;
delete[] Signal_volt; delete[] Signal_volt;
delete[] Signal_curr; delete[] Signal_curr;
Signal_volt = new FDTD_FLOAT[Length+1]; Signal_volt = new FDTD_FLOAT[Length+1];

View File

@ -40,6 +40,10 @@ void Engine_Ext_Excitation::Apply2Voltages()
unsigned int length = m_Op_Exc->m_Exc->GetLength(); unsigned int length = m_Op_Exc->m_Exc->GetLength();
FDTD_FLOAT* exc_volt = m_Op_Exc->m_Exc->GetVoltageSignal(); FDTD_FLOAT* exc_volt = m_Op_Exc->m_Exc->GetVoltageSignal();
int p = int(m_Op_Exc->m_Exc->GetSignalPeriod()/m_Op_Exc->m_Exc->GetTimestep());
if (p>0)
numTS = (numTS % p) + p;
//switch for different engine types to access faster inline engine functions //switch for different engine types to access faster inline engine functions
switch (m_Eng->GetType()) switch (m_Eng->GetType())
{ {
@ -100,6 +104,10 @@ void Engine_Ext_Excitation::Apply2Current()
unsigned int length = m_Op_Exc->m_Exc->GetLength(); unsigned int length = m_Op_Exc->m_Exc->GetLength();
FDTD_FLOAT* exc_curr = m_Op_Exc->m_Exc->GetCurrentSignal(); FDTD_FLOAT* exc_curr = m_Op_Exc->m_Exc->GetCurrentSignal();
int p = int(m_Op_Exc->m_Exc->GetSignalPeriod()/m_Op_Exc->m_Exc->GetTimestep());
if (p>0)
numTS = (numTS % p) + p;
//switch for different engine types to access faster inline engine functions //switch for different engine types to access faster inline engine functions
switch (m_Eng->GetType()) switch (m_Eng->GetType())
{ {

View File

@ -38,14 +38,18 @@ void Engine_Ext_TFSF::DoPostVoltageUpdates()
unsigned int numTS = m_Eng->GetNumberOfTimesteps(); unsigned int numTS = m_Eng->GetNumberOfTimesteps();
unsigned int length = m_Op_TFSF->m_Exc->GetLength(); unsigned int length = m_Op_TFSF->m_Exc->GetLength();
int p = int(m_Op_TFSF->m_Exc->GetSignalPeriod()/m_Op_TFSF->m_Exc->GetTimestep());
for (unsigned int n=0;n<=m_Op_TFSF->m_maxDelay;++n) for (unsigned int n=0;n<=m_Op_TFSF->m_maxDelay;++n)
{ {
if ( numTS < n ) if ( numTS < n )
m_DelayLookup[n]=0; m_DelayLookup[n]=0;
else if ( numTS-n > length) else if ((numTS-n > length) && (p==0))
m_DelayLookup[n]=0; m_DelayLookup[n]=0;
else else
m_DelayLookup[n] = numTS - n; m_DelayLookup[n] = numTS - n;
if (p>0)
m_DelayLookup[n] = (m_DelayLookup[n] % p);
} }
//get the current signal since an H-field is added ... //get the current signal since an H-field is added ...
@ -124,14 +128,18 @@ void Engine_Ext_TFSF::DoPostCurrentUpdates()
unsigned int numTS = m_Eng->GetNumberOfTimesteps(); unsigned int numTS = m_Eng->GetNumberOfTimesteps();
unsigned int length = m_Op_TFSF->m_Exc->GetLength(); unsigned int length = m_Op_TFSF->m_Exc->GetLength();
int p = int(m_Op_TFSF->m_Exc->GetSignalPeriod()/m_Op_TFSF->m_Exc->GetTimestep());
for (unsigned int n=0;n<m_Op_TFSF->m_maxDelay;++n) for (unsigned int n=0;n<m_Op_TFSF->m_maxDelay;++n)
{ {
if ( numTS < n ) if ( numTS < n )
m_DelayLookup[n]=0; m_DelayLookup[n]=0;
else if ( numTS-n > length) else if ((numTS-n > length) && (p==0))
m_DelayLookup[n]=0; m_DelayLookup[n]=0;
else else
m_DelayLookup[n] = numTS - n; m_DelayLookup[n] = numTS - n;
if (p>0)
m_DelayLookup[n] = (m_DelayLookup[n] % p);
} }
//get the current signal since an E-field is added ... //get the current signal since an E-field is added ...

View File

@ -805,11 +805,23 @@ int openEMS::SetupFDTD(const char* file)
if (m_Exc->GetNyquistNum()>1000) if (m_Exc->GetNyquistNum()>1000)
cerr << "openEMS::SetupFDTD: Warning, the timestep seems to be very small --> long simulation. Check your mesh!?" << endl; cerr << "openEMS::SetupFDTD: Warning, the timestep seems to be very small --> long simulation. Check your mesh!?" << endl;
cout << "Excitation signal length is: " << m_Exc->GetLength() << " timesteps (" << m_Exc->GetLength()*FDTD_Op->GetTimestep() << "s)" << endl; if (m_Exc->GetSignalPeriod()==0)
cout << "Max. number of timesteps: " << NrTS << " ( --> " << (double)NrTS/(double)(m_Exc->GetLength()) << " * Excitation signal length)" << endl; {
if ( ((double)NrTS/(double)m_Exc->GetLength() < 3) && (m_Exc->GetExciteType()==0)) cout << "Excitation signal length is: " << m_Exc->GetLength() << " timesteps (" << m_Exc->GetLength()*FDTD_Op->GetTimestep() << "s)" << endl;
cerr << "openEMS::SetupFDTD: Warning, max. number of timesteps is smaller than three times the excitation. " << endl << \ cout << "Max. number of timesteps: " << NrTS << " ( --> " << (double)NrTS/(double)(m_Exc->GetLength()) << " * Excitation signal length)" << endl;
"\tYou may want to choose a higher number of max. timesteps... " << endl; if ( ((double)NrTS/(double)m_Exc->GetLength() < 3) && (m_Exc->GetExciteType()==0))
cerr << "openEMS::SetupFDTD: Warning, max. number of timesteps is smaller than three times the excitation. " << endl << \
"\tYou may want to choose a higher number of max. timesteps... " << endl;
}
else
{
int p = int(m_Exc->GetSignalPeriod()/FDTD_Op->GetTimestep());
cout << "Excitation signal period is: " << p << " timesteps (" << m_Exc->GetSignalPeriod() << "s)" << endl;
cout << "Max. number of timesteps: " << NrTS << " ( --> " << (double)NrTS/(double)(m_Exc->GetLength()) << " * Excitation signal period)" << endl;
if (NrTS/p < 3)
cerr << "openEMS::SetupFDTD: Warning, max. number of timesteps is smaller than three times the excitation signal period. " << endl << \
"\tYou may want to choose a higher number of max. timesteps... " << endl;
}
if (m_no_simulation) if (m_no_simulation)
{ {