2010-05-03 16:33:14 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2010 Thorsten Liebig (Thorsten.Liebig@gmx.de)
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef EXCITATION_H
|
|
|
|
#define EXCITATION_H
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
|
|
|
#include "tools/constants.h"
|
|
|
|
|
|
|
|
class Excitation
|
|
|
|
{
|
|
|
|
public:
|
2015-12-13 21:33:26 +00:00
|
|
|
enum ExciteTypes {UNDEFINED=-1, GaissianPulse=0, Sinusoidal=1, DiracPulse=2, Step=3, CustomExcite=10};
|
2012-07-17 11:23:00 +00:00
|
|
|
Excitation();
|
2010-05-03 16:33:14 +00:00
|
|
|
virtual ~Excitation();
|
|
|
|
|
2011-07-25 12:56:27 +00:00
|
|
|
virtual void Reset( double timestep );
|
|
|
|
|
2015-12-13 21:33:26 +00:00
|
|
|
bool SetupGaussianPulse(double f0, double fc);
|
|
|
|
bool SetupSinusoidal(double f0);
|
|
|
|
bool SetupDiracPulse(double fmax);
|
|
|
|
bool SetupStepExcite(double fmax);
|
|
|
|
bool SetupCustomExcite(std::string str, double f0, double fmax);
|
|
|
|
|
|
|
|
double GetCenterFreq() {return m_f0;}
|
|
|
|
double GetCutOffFreq() {return m_fc;}
|
|
|
|
double GetMaxFreq() {return m_f_max;}
|
|
|
|
|
2015-05-04 18:47:19 +00:00
|
|
|
bool buildExcitationSignal(unsigned int maxTS);
|
2010-05-03 16:33:14 +00:00
|
|
|
|
|
|
|
//! Get the excitation timestep with the (first) max amplitude
|
|
|
|
virtual unsigned int GetMaxExcitationTimestep() const;
|
|
|
|
|
|
|
|
void SetNyquistNum(unsigned int nyquist) {m_nyquistTS=nyquist;}
|
|
|
|
unsigned int GetNyquistNum() const {return m_nyquistTS;}
|
|
|
|
|
2011-03-08 12:35:38 +00:00
|
|
|
//! Dump voltage excitation signal to ASCII file
|
2015-06-18 19:45:22 +00:00
|
|
|
void DumpVoltageExcite(std::string filename);
|
2011-03-08 12:35:38 +00:00
|
|
|
|
|
|
|
//! Dump current excitation signal to ASCII file
|
2015-06-18 19:45:22 +00:00
|
|
|
void DumpCurrentExcite(std::string filename);
|
2011-03-08 12:35:38 +00:00
|
|
|
|
2011-03-16 15:26:01 +00:00
|
|
|
//! Get the used timestep
|
|
|
|
double GetTimestep() const {return dT;}
|
|
|
|
|
2012-01-17 10:31:53 +00:00
|
|
|
//! Get the type of excitation
|
|
|
|
int GetExciteType() const {return m_Excit_Type;}
|
|
|
|
|
2012-07-16 15:15:10 +00:00
|
|
|
//! Get the length of the excitation signal
|
|
|
|
unsigned int GetLength() const {return Length;}
|
2010-05-03 16:33:14 +00:00
|
|
|
|
2012-07-23 10:09:16 +00:00
|
|
|
//! Get the max frequeny excited by this signal
|
|
|
|
double GetMaxFrequency() const {return m_f_max;}
|
|
|
|
|
|
|
|
//! Get the frequency of interest
|
|
|
|
double GetFrequencyOfInterest() const {return m_foi;}
|
|
|
|
|
2015-05-04 18:47:19 +00:00
|
|
|
//! Get the signal period, 0 if not a periodical signal
|
|
|
|
double GetSignalPeriod() const {return m_SignalPeriod;}
|
|
|
|
|
2012-07-16 15:15:10 +00:00
|
|
|
FDTD_FLOAT* GetVoltageSignal() const {return Signal_volt;}
|
|
|
|
FDTD_FLOAT* GetCurrentSignal() const {return Signal_curr;}
|
2010-05-03 16:33:14 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
double dT;
|
|
|
|
unsigned int m_nyquistTS;
|
2015-05-04 18:47:19 +00:00
|
|
|
double m_SignalPeriod;
|
2015-12-13 21:33:26 +00:00
|
|
|
ExciteTypes m_Excit_Type;
|
2015-05-04 18:47:19 +00:00
|
|
|
|
2012-07-16 15:15:10 +00:00
|
|
|
//Excitation time-signal
|
|
|
|
unsigned int Length;
|
|
|
|
FDTD_FLOAT* Signal_volt;
|
|
|
|
FDTD_FLOAT* Signal_curr;
|
|
|
|
|
2015-12-13 21:33:26 +00:00
|
|
|
// center frequency
|
|
|
|
double m_f0;
|
|
|
|
|
|
|
|
// cutoff-frequency (Gaussian pulse only)
|
|
|
|
double m_fc;
|
|
|
|
|
|
|
|
std::string m_CustomExc_Str;
|
|
|
|
|
2012-07-23 10:09:16 +00:00
|
|
|
// max frequency
|
|
|
|
double m_f_max;
|
|
|
|
// frequency of interest
|
|
|
|
double m_foi;
|
|
|
|
|
2010-05-03 16:33:14 +00:00
|
|
|
//! Calculate a custom signal
|
2015-06-18 19:45:22 +00:00
|
|
|
virtual void CalcCustomExcitation(double f0, int nTS, std::string signal);
|
2010-07-16 08:41:12 +00:00
|
|
|
//! Calculate an excitation with center of \a f0 and the half bandwidth \a fc
|
2010-05-05 15:28:00 +00:00
|
|
|
virtual void CalcGaussianPulsExcitation(double f0, double fc, int nTS);
|
2010-07-16 08:41:12 +00:00
|
|
|
//! Calculate a sinusoidal excitation with frequency \a f0 and a duration of \a nTS number of timesteps
|
2010-05-03 16:33:14 +00:00
|
|
|
virtual void CalcSinusExcitation(double f0, int nTS);
|
|
|
|
//! Calculate a dirac impuls excitation
|
|
|
|
virtual void CalcDiracPulsExcitation();
|
|
|
|
//! Calculate a step excitation
|
|
|
|
virtual void CalcStepExcitation();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // EXCITATION_H
|