2010-02-28 21:48:03 +00:00
|
|
|
#include <iostream>
|
2010-03-01 18:35:28 +00:00
|
|
|
#include <fstream>
|
|
|
|
#include <sstream>
|
2010-02-28 21:48:03 +00:00
|
|
|
#include <time.h>
|
2010-03-01 18:35:28 +00:00
|
|
|
#include "tools/array_ops.h"
|
2010-02-28 21:48:03 +00:00
|
|
|
#include "FDTD/cartoperator.h"
|
2010-03-01 13:56:27 +00:00
|
|
|
#include "FDTD/engine.h"
|
2010-03-01 18:35:28 +00:00
|
|
|
#include "FDTD/processvoltage.h"
|
2010-03-01 13:56:27 +00:00
|
|
|
|
2010-02-28 21:48:03 +00:00
|
|
|
#include "ContinuousStructure.h"
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
2010-02-28 22:42:10 +00:00
|
|
|
void BuildMSL(ContinuousStructure &CSX);
|
2010-03-01 19:50:42 +00:00
|
|
|
void BuildDipol(ContinuousStructure &CSX);
|
2010-02-28 22:42:10 +00:00
|
|
|
|
2010-02-28 21:48:03 +00:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
time_t startTime=time(NULL);
|
|
|
|
|
2010-03-01 18:35:28 +00:00
|
|
|
//*************** setup/read geometry ************//
|
|
|
|
ContinuousStructure CSX;
|
2010-03-01 19:50:42 +00:00
|
|
|
BuildDipol(CSX);
|
2010-02-28 21:48:03 +00:00
|
|
|
|
2010-03-01 18:35:28 +00:00
|
|
|
//*************** setup operator ************//
|
2010-02-28 21:48:03 +00:00
|
|
|
CartOperator cop;
|
|
|
|
cop.SetGeometryCSX(&CSX);
|
|
|
|
|
|
|
|
cop.CalcECOperator();
|
|
|
|
|
2010-03-01 18:35:28 +00:00
|
|
|
double fmax=1e9;
|
|
|
|
cop.CalcGaussianPulsExcitation(fmax/2,fmax/2);
|
2010-03-01 13:56:27 +00:00
|
|
|
|
2010-02-28 21:48:03 +00:00
|
|
|
time_t OpDoneTime=time(NULL);
|
|
|
|
|
2010-03-01 13:56:27 +00:00
|
|
|
cop.ShowSize();
|
|
|
|
|
2010-03-01 18:35:28 +00:00
|
|
|
// cop.DumpOperator2File("tmp/Operator");
|
|
|
|
|
|
|
|
cerr << "Nyquist number of timesteps: " << cop.GetNyquistNum(fmax) << endl;
|
2010-03-01 19:50:42 +00:00
|
|
|
unsigned int NrIter = cop.GetNyquistNum(fmax)/3;
|
2010-03-01 18:35:28 +00:00
|
|
|
|
2010-02-28 21:48:03 +00:00
|
|
|
cerr << "Time for operator: " << difftime(OpDoneTime,startTime) << endl;
|
|
|
|
|
2010-03-01 18:35:28 +00:00
|
|
|
//create FDTD engine
|
2010-03-01 13:56:27 +00:00
|
|
|
Engine eng(&cop);
|
|
|
|
|
|
|
|
time_t currTime = time(NULL);
|
|
|
|
|
2010-03-01 18:35:28 +00:00
|
|
|
//*************** setup processing ************//
|
|
|
|
ProcessVoltage PV(&cop,&eng);
|
|
|
|
PV.OpenFile("tmp/u1");
|
2010-03-01 19:50:42 +00:00
|
|
|
double start[]={-500,-150,0};
|
|
|
|
double stop[]={-500,150,0};
|
2010-03-01 18:35:28 +00:00
|
|
|
PV.DefineStartStopCoord(start,stop);
|
|
|
|
unsigned int maxIter = 5000;
|
|
|
|
|
2010-03-01 19:50:42 +00:00
|
|
|
PV.Process();
|
|
|
|
// NrIter=200;
|
2010-03-01 18:35:28 +00:00
|
|
|
//*************** simulate ************//
|
|
|
|
for (unsigned int i=0;i<maxIter;i+=NrIter)
|
|
|
|
{
|
|
|
|
eng.IterateTS(NrIter);
|
|
|
|
PV.Process();
|
|
|
|
}
|
|
|
|
|
|
|
|
//*************** postproc ************//
|
2010-03-01 13:56:27 +00:00
|
|
|
time_t prevTime = currTime;
|
|
|
|
currTime = time(NULL);
|
|
|
|
|
|
|
|
double t_diff = difftime(currTime,prevTime);
|
|
|
|
|
2010-03-01 18:35:28 +00:00
|
|
|
cerr << "Time for " << eng.GetNumberOfTimesteps() << " iterations with " << cop.GetNumberCells() << " cells : " << t_diff << " sec" << endl;
|
|
|
|
cerr << "Speed (MCells/s): " << (double)cop.GetNumberCells()*(double)eng.GetNumberOfTimesteps()/t_diff/1e6 << endl;
|
2010-02-28 21:48:03 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2010-02-28 22:42:10 +00:00
|
|
|
|
2010-03-01 19:50:42 +00:00
|
|
|
void BuildDipol(ContinuousStructure &CSX)
|
|
|
|
{
|
|
|
|
CSPropMaterial* mat = new CSPropMaterial(CSX.GetParameterSet());
|
|
|
|
mat->SetKappa(0.001);
|
|
|
|
CSX.AddProperty(mat);
|
|
|
|
|
|
|
|
CSPrimBox* matbox = new CSPrimBox(CSX.GetParameterSet(),mat);
|
|
|
|
matbox->SetCoord(0,-1000.0);matbox->SetCoord(1,1000.0);
|
|
|
|
matbox->SetCoord(2,-1000.0);matbox->SetCoord(3,1000.0);
|
|
|
|
matbox->SetCoord(4,-1000.0);matbox->SetCoord(5,1000.0);
|
|
|
|
CSX.AddPrimitive(matbox);
|
|
|
|
|
|
|
|
CSPropElectrode* elec = new CSPropElectrode(CSX.GetParameterSet());
|
|
|
|
elec->SetExcitation(1,1);
|
|
|
|
elec->SetExcitType(0);
|
|
|
|
// elec->SetDelay(2.0e-9);
|
|
|
|
CSX.AddProperty(elec);
|
|
|
|
|
|
|
|
CSPrimBox* box = new CSPrimBox(CSX.GetParameterSet(),elec);
|
|
|
|
box->SetCoord(0,-1.0);box->SetCoord(1,1.0);
|
|
|
|
box->SetCoord(2,-75.0);box->SetCoord(3,75.0);
|
|
|
|
box->SetCoord(4,-1.0);box->SetCoord(5,1.0);
|
|
|
|
CSX.AddPrimitive(box);
|
|
|
|
|
|
|
|
CSRectGrid* grid = CSX.GetGrid();
|
|
|
|
|
|
|
|
for (int n=-1000;n<=1000;n+=20)
|
|
|
|
grid->AddDiscLine(2,(double)n);
|
|
|
|
for (int n=-1000;n<=1000;n+=20)
|
|
|
|
grid->AddDiscLine(0,(double)n);
|
|
|
|
for (int n=-1000;n<=1000;n+=20)
|
|
|
|
grid->AddDiscLine(1,(double)n);
|
|
|
|
|
|
|
|
grid->SetDeltaUnit(1e-3);
|
|
|
|
|
|
|
|
CSX.Write2XML("tmp/Dipol.xml");
|
|
|
|
}
|
|
|
|
|
2010-02-28 22:42:10 +00:00
|
|
|
void BuildMSL(ContinuousStructure &CSX)
|
|
|
|
{
|
2010-03-01 18:35:28 +00:00
|
|
|
// CSPropMaterial* mat = new CSPropMaterial(CSX.GetParameterSet());
|
|
|
|
// mat->SetEpsilon(3.6);
|
|
|
|
// CSX.AddProperty(mat);
|
|
|
|
//
|
|
|
|
// CSPrimBox* box = new CSPrimBox(CSX.GetParameterSet(),mat);
|
|
|
|
// box->SetCoord(0,-200.0);box->SetCoord(1,200.0);
|
|
|
|
// box->SetCoord(2,0.0);box->SetCoord(3,50.0);
|
|
|
|
// box->SetCoord(4,-1000.0);box->SetCoord(5,1000.0);
|
|
|
|
// CSX.AddPrimitive(box);
|
|
|
|
//
|
|
|
|
// CSPropMaterial* MSL = new CSPropMaterial(CSX.GetParameterSet());
|
|
|
|
// MSL->SetKappa(56e6);
|
|
|
|
// CSX.AddProperty(MSL);
|
|
|
|
//
|
|
|
|
// box = new CSPrimBox(CSX.GetParameterSet(),MSL);
|
|
|
|
// box->SetCoord(0,-20.0);box->SetCoord(1,20.0);
|
|
|
|
// box->SetCoord(2,0.0);box->SetCoord(3,50.0);
|
|
|
|
// box->SetCoord(4,-1000.0);box->SetCoord(5,1000.0);
|
|
|
|
// CSX.AddPrimitive(box);
|
2010-02-28 22:42:10 +00:00
|
|
|
|
|
|
|
CSPropElectrode* elec = new CSPropElectrode(CSX.GetParameterSet());
|
|
|
|
elec->SetExcitation(1,1);
|
|
|
|
elec->SetExcitType(0);
|
2010-03-01 13:56:27 +00:00
|
|
|
// elec->SetDelay(2.0e-9);
|
2010-02-28 22:42:10 +00:00
|
|
|
CSX.AddProperty(elec);
|
|
|
|
|
2010-03-01 18:35:28 +00:00
|
|
|
CSPrimBox* box = new CSPrimBox(CSX.GetParameterSet(),elec);
|
|
|
|
box->SetCoord(0,-1.0);box->SetCoord(1,1.0);
|
2010-02-28 22:42:10 +00:00
|
|
|
box->SetCoord(2,0.0);box->SetCoord(3,50.0);
|
2010-03-01 18:35:28 +00:00
|
|
|
box->SetCoord(4,-1.0);box->SetCoord(5,1.0);
|
2010-02-28 22:42:10 +00:00
|
|
|
CSX.AddPrimitive(box);
|
|
|
|
|
|
|
|
CSRectGrid* grid = CSX.GetGrid();
|
|
|
|
|
2010-03-01 19:50:42 +00:00
|
|
|
for (int n=-300;n<=300;n+=20)
|
2010-02-28 22:42:10 +00:00
|
|
|
grid->AddDiscLine(0,(double)n);
|
2010-03-01 19:50:42 +00:00
|
|
|
for (int n=0;n<=300;n+=20)
|
2010-02-28 22:42:10 +00:00
|
|
|
grid->AddDiscLine(1,(double)n);
|
2010-03-01 19:50:42 +00:00
|
|
|
for (int n=-1000;n<=1000;n+=20)
|
|
|
|
grid->AddDiscLine(2,(double)n);
|
2010-02-28 22:42:10 +00:00
|
|
|
|
2010-03-01 07:43:31 +00:00
|
|
|
grid->SetDeltaUnit(1e-3);
|
|
|
|
|
2010-03-01 19:50:42 +00:00
|
|
|
CSX.Write2XML("tmp/MSL.xml");
|
2010-02-28 22:42:10 +00:00
|
|
|
}
|