Merge branch 'master' into sse
Conflicts: FDTD/engine.h openEMS.pro openems.cpppull/1/head
commit
885fc8ee26
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
|
||||
#include "engine.h"
|
||||
#include "engine_extension.h"
|
||||
#include "operator_extension.h"
|
||||
#include "tools/array_ops.h"
|
||||
|
||||
//! \brief construct an Engine instance
|
||||
|
@ -34,10 +36,25 @@ Engine::Engine(const Operator* op)
|
|||
{
|
||||
numLines[n] = Op->GetNumberOfLines(n);
|
||||
}
|
||||
|
||||
for (size_t n=0;n<Op->GetNumberOfExtentions();++n)
|
||||
{
|
||||
Operator_Extension* op_ext = Op->GetExtension(n);
|
||||
Engine_Extension* eng_ext = op_ext->CreateEngineExtention();
|
||||
if (eng_ext)
|
||||
{
|
||||
eng_ext->SetEngine(this);
|
||||
m_Eng_exts.push_back(eng_ext);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Engine::~Engine()
|
||||
{
|
||||
for (size_t n=0;n<m_Eng_exts.size();++n)
|
||||
delete m_Eng_exts.at(n);
|
||||
m_Eng_exts.clear();
|
||||
|
||||
this->Reset();
|
||||
}
|
||||
|
||||
|
@ -46,6 +63,8 @@ void Engine::Init()
|
|||
numTS = 0;
|
||||
volt = Create_N_3DArray(numLines);
|
||||
curr = Create_N_3DArray(numLines);
|
||||
|
||||
file_et1.open( "et1" );
|
||||
}
|
||||
|
||||
void Engine::Reset()
|
||||
|
@ -54,6 +73,8 @@ void Engine::Reset()
|
|||
volt=NULL;
|
||||
Delete_N_3DArray(curr,numLines);
|
||||
curr=NULL;
|
||||
|
||||
file_et1.close();
|
||||
}
|
||||
|
||||
void Engine::UpdateVoltages()
|
||||
|
@ -99,6 +120,13 @@ void Engine::ApplyVoltageExcite()
|
|||
// if (n==0) cerr << numTS << " => " << Op->ExciteSignal[exc_pos] << endl;
|
||||
volt[Op->E_Exc_dir[n]][Op->E_Exc_index[0][n]][Op->E_Exc_index[1][n]][Op->E_Exc_index[2][n]] += Op->E_Exc_amp[n]*Op->ExciteSignal[exc_pos];
|
||||
}
|
||||
|
||||
// write the first excitation into the file "et1"
|
||||
if (Op->E_Exc_Count >= 1) {
|
||||
exc_pos = (int)numTS - (int)Op->E_Exc_delay[0];
|
||||
exc_pos *= (exc_pos>0 && exc_pos<=(int)Op->ExciteLength);
|
||||
file_et1 << numTS * Op->GetTimestep() << "\t" << Op->E_Exc_amp[0]*Op->ExciteSignal[exc_pos] << "\n"; // do not use std::endl here, because it will do an implicit flush
|
||||
}
|
||||
}
|
||||
|
||||
void Engine::UpdateCurrents()
|
||||
|
@ -135,10 +163,32 @@ bool Engine::IterateTS(unsigned int iterTS)
|
|||
{
|
||||
for (unsigned int iter=0;iter<iterTS;++iter)
|
||||
{
|
||||
//voltage updates with extensions
|
||||
for (size_t n=0;n<m_Eng_exts.size();++n)
|
||||
m_Eng_exts.at(n)->DoPreVoltageUpdates();
|
||||
|
||||
UpdateVoltages();
|
||||
|
||||
for (size_t n=0;n<m_Eng_exts.size();++n)
|
||||
m_Eng_exts.at(n)->DoPostVoltageUpdates();
|
||||
for (size_t n=0;n<m_Eng_exts.size();++n)
|
||||
m_Eng_exts.at(n)->Apply2Voltages();
|
||||
|
||||
ApplyVoltageExcite();
|
||||
|
||||
//current updates with extensions
|
||||
for (size_t n=0;n<m_Eng_exts.size();++n)
|
||||
m_Eng_exts.at(n)->DoPreCurrentUpdates();
|
||||
|
||||
UpdateCurrents();
|
||||
|
||||
for (size_t n=0;n<m_Eng_exts.size();++n)
|
||||
m_Eng_exts.at(n)->DoPostCurrentUpdates();
|
||||
for (size_t n=0;n<m_Eng_exts.size();++n)
|
||||
m_Eng_exts.at(n)->Apply2Current();
|
||||
|
||||
ApplyCurrentExcite();
|
||||
|
||||
++numTS;
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -18,8 +18,11 @@
|
|||
#ifndef ENGINE_H
|
||||
#define ENGINE_H
|
||||
|
||||
#include <fstream>
|
||||
#include "operator.h"
|
||||
|
||||
class Engine_Extension;
|
||||
|
||||
class Engine
|
||||
{
|
||||
public:
|
||||
|
@ -37,6 +40,9 @@ public:
|
|||
inline virtual FDTD_FLOAT GetVolt( unsigned int n, unsigned int x, unsigned int y, unsigned int z ) const { return volt[n][x][y][z]; }
|
||||
inline virtual FDTD_FLOAT GetCurr( unsigned int n, unsigned int x, unsigned int y, unsigned int z ) const { return curr[n][x][y][z]; }
|
||||
|
||||
inline virtual FDTD_FLOAT& GetVolt( unsigned int n, unsigned int pos[] ) { return volt[n][pos[0]][pos[1]][pos[2]]; }
|
||||
inline virtual FDTD_FLOAT& GetCurr( unsigned int n, unsigned int pos[] ) { return curr[n][pos[0]][pos[1]][pos[2]]; }
|
||||
|
||||
protected:
|
||||
Engine(const Operator* op);
|
||||
const Operator* Op;
|
||||
|
@ -51,6 +57,10 @@ protected:
|
|||
FDTD_FLOAT**** volt;
|
||||
FDTD_FLOAT**** curr;
|
||||
unsigned int numTS;
|
||||
|
||||
vector<Engine_Extension*> m_Eng_exts;
|
||||
|
||||
ofstream file_et1;
|
||||
};
|
||||
|
||||
#endif // ENGINE_H
|
||||
|
|
|
@ -0,0 +1,105 @@
|
|||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#include "engine_ext_mur_abc.h"
|
||||
#include "operator_ext_mur_abc.h"
|
||||
#include "engine.h"
|
||||
#include "tools/array_ops.h"
|
||||
|
||||
Engine_Ext_Mur_ABC::Engine_Ext_Mur_ABC(Operator_Ext_Mur_ABC* op_ext) : Engine_Extension(op_ext)
|
||||
{
|
||||
m_Op_mur = op_ext;
|
||||
m_numLines[0] = m_Op_mur->m_numLines[0];
|
||||
m_numLines[1] = m_Op_mur->m_numLines[1];
|
||||
m_ny = m_Op_mur->m_ny;
|
||||
m_nyP = m_Op_mur->m_nyP;
|
||||
m_nyPP = m_Op_mur->m_nyPP;
|
||||
m_LineNr = m_Op_mur->m_LineNr;
|
||||
m_LineNr_Shift = m_Op_mur->m_LineNr_Shift;
|
||||
|
||||
m_Mur_Coeff = m_Op_mur->m_Mur_Coeff;
|
||||
|
||||
m_volt_nyP = Create2DArray(m_numLines);
|
||||
m_volt_nyPP = Create2DArray(m_numLines);
|
||||
}
|
||||
|
||||
Engine_Ext_Mur_ABC::~Engine_Ext_Mur_ABC()
|
||||
{
|
||||
Delete2DArray(m_volt_nyP,m_numLines);
|
||||
m_volt_nyP = NULL;
|
||||
Delete2DArray(m_volt_nyPP,m_numLines);
|
||||
m_volt_nyPP = NULL;
|
||||
}
|
||||
|
||||
void Engine_Ext_Mur_ABC::DoPreVoltageUpdates()
|
||||
{
|
||||
if (m_Eng==NULL) return;
|
||||
if (m_Mur_Coeff==0) return;
|
||||
unsigned int pos[] = {0,0,0};
|
||||
unsigned int pos_shift[] = {0,0,0};
|
||||
pos[m_ny] = m_LineNr;
|
||||
pos_shift[m_ny] = m_LineNr_Shift;
|
||||
|
||||
for (pos[m_nyP]=0;pos[m_nyP]<m_numLines[0];++pos[m_nyP])
|
||||
{
|
||||
pos_shift[m_nyP] = pos[m_nyP];
|
||||
for (pos[m_nyPP]=0;pos[m_nyPP]<m_numLines[1];++pos[m_nyPP])
|
||||
{
|
||||
pos_shift[m_nyPP] = pos[m_nyPP];
|
||||
m_volt_nyP[pos[m_nyP]][pos[m_nyPP]] = m_Eng->GetVolt(m_nyP,pos_shift) - m_Mur_Coeff * m_Eng->GetVolt(m_nyP,pos);
|
||||
m_volt_nyPP[pos[m_nyP]][pos[m_nyPP]] = m_Eng->GetVolt(m_nyPP,pos_shift) - m_Mur_Coeff * m_Eng->GetVolt(m_nyPP,pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Engine_Ext_Mur_ABC::DoPostVoltageUpdates()
|
||||
{
|
||||
if (m_Eng==NULL) return;
|
||||
if (m_Mur_Coeff==0) return;
|
||||
unsigned int pos[] = {0,0,0};
|
||||
unsigned int pos_shift[] = {0,0,0};
|
||||
pos[m_ny] = m_LineNr;
|
||||
pos_shift[m_ny] = m_LineNr_Shift;
|
||||
|
||||
for (pos[m_nyP]=0;pos[m_nyP]<m_numLines[0];++pos[m_nyP])
|
||||
{
|
||||
pos_shift[m_nyP] = pos[m_nyP];
|
||||
for (pos[m_nyPP]=0;pos[m_nyPP]<m_numLines[1];++pos[m_nyPP])
|
||||
{
|
||||
pos_shift[m_nyPP] = pos[m_nyPP];
|
||||
m_volt_nyP[pos[m_nyP]][pos[m_nyPP]] += m_Mur_Coeff * m_Eng->GetVolt(m_nyP,pos_shift);
|
||||
m_volt_nyPP[pos[m_nyP]][pos[m_nyPP]] += m_Mur_Coeff * m_Eng->GetVolt(m_nyPP,pos_shift);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Engine_Ext_Mur_ABC::Apply2Voltages()
|
||||
{
|
||||
if (m_Eng==NULL) return;
|
||||
if (m_Mur_Coeff==0) return;
|
||||
unsigned int pos[] = {0,0,0};
|
||||
pos[m_ny] = m_LineNr;
|
||||
|
||||
for (pos[m_nyP]=0;pos[m_nyP]<m_numLines[0];++pos[m_nyP])
|
||||
{
|
||||
for (pos[m_nyPP]=0;pos[m_nyPP]<m_numLines[1];++pos[m_nyPP])
|
||||
{
|
||||
m_Eng->GetVolt(m_nyP,pos) = m_volt_nyP[pos[m_nyP]][pos[m_nyPP]];
|
||||
m_Eng->GetVolt(m_nyPP,pos) = m_volt_nyPP[pos[m_nyP]][pos[m_nyPP]];
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* 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 ENGINE_EXT_MUR_ABC_H
|
||||
#define ENGINE_EXT_MUR_ABC_H
|
||||
|
||||
#include "engine_extension.h"
|
||||
#include "operator.h"
|
||||
|
||||
class Operator_Ext_Mur_ABC;
|
||||
|
||||
class Engine_Ext_Mur_ABC : public Engine_Extension
|
||||
{
|
||||
public:
|
||||
Engine_Ext_Mur_ABC(Operator_Ext_Mur_ABC* op_ext);
|
||||
virtual ~Engine_Ext_Mur_ABC();
|
||||
|
||||
virtual void DoPreVoltageUpdates();
|
||||
virtual void DoPostVoltageUpdates();
|
||||
virtual void Apply2Voltages();
|
||||
|
||||
protected:
|
||||
Operator_Ext_Mur_ABC* m_Op_mur;
|
||||
|
||||
int m_ny;
|
||||
int m_nyP,m_nyPP;
|
||||
unsigned int m_LineNr;
|
||||
int m_LineNr_Shift;
|
||||
unsigned int m_numLines[2];
|
||||
|
||||
FDTD_FLOAT m_Mur_Coeff;
|
||||
FDTD_FLOAT** m_volt_nyP; //n+1 direction
|
||||
FDTD_FLOAT** m_volt_nyPP; //n+2 direction
|
||||
};
|
||||
|
||||
#endif // ENGINE_EXT_MUR_ABC_H
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#include "engine_extension.h"
|
||||
|
||||
#include "engine.h"
|
||||
|
||||
Engine_Extension::Engine_Extension(Operator_Extension* op_ext)
|
||||
{
|
||||
m_Op_ext = op_ext;
|
||||
m_Eng = NULL;
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* 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 ENGINE_EXTENSION_H
|
||||
#define ENGINE_EXTENSION_H
|
||||
|
||||
class Operator_Extension;
|
||||
class Engine;
|
||||
|
||||
//! Abstract base-class for all engine extensions
|
||||
class Engine_Extension
|
||||
{
|
||||
public:
|
||||
//! This methode will be called __before__ the main engine does the usual voltage updates. This methode may __not__ change the engine voltages!!!
|
||||
virtual void DoPreVoltageUpdates() {}
|
||||
//! This methode will be called __after__ the main engine does the usual voltage updates. This methode may __not__ change the engine voltages!!!
|
||||
virtual void DoPostVoltageUpdates() {}
|
||||
//! This methode will be called __after__ all updates to the voltages and extensions and may add/set its results to the engine voltages, but may __not__ rely on the current value of the engine voltages!!!
|
||||
virtual void Apply2Voltages() {}
|
||||
|
||||
//! This methode will be called __before__ the main engine does the usual current updates. This methode may __not__ change the engine current!!!
|
||||
virtual void DoPreCurrentUpdates() {}
|
||||
//! This methode will be called __after__ the main engine does the usual current updates. This methode may __not__ change the engine current!!!
|
||||
virtual void DoPostCurrentUpdates() {}
|
||||
//! This methode will be called __after__ all updates to the current and extensions and may add/set its results to the engine current, but may __not__ rely on the current value of the engine current!!!
|
||||
virtual void Apply2Current() {}
|
||||
|
||||
//! Set the Engine to this extention. This will usually done automatically by Engine::AddExtension
|
||||
virtual void SetEngine(Engine* eng) {m_Eng=eng;}
|
||||
protected:
|
||||
Engine_Extension(Operator_Extension* op_ext);
|
||||
|
||||
Operator_Extension* m_Op_ext;
|
||||
Engine* m_Eng;
|
||||
};
|
||||
|
||||
#endif // ENGINE_EXTENSION_H
|
|
@ -275,24 +275,13 @@ void thread_e_excitation::operator()()
|
|||
//std::cout << "thread_e_excitation::operator()" << std::endl;
|
||||
//DBG().cout() << "Thread e_excitation (" << boost::this_thread::get_id() << ") started." << endl;
|
||||
|
||||
int exc_pos;
|
||||
const unsigned int E_Exc_Count = m_enginePtr->Op->E_Exc_Count;
|
||||
|
||||
while (!m_enginePtr->m_stopThreads)
|
||||
{
|
||||
// waiting on NS_Engine_Multithread::thread
|
||||
m_enginePtr->m_barrier1->wait();
|
||||
m_enginePtr->m_barrier1->wait(); // waiting on NS_Engine_Multithread::thread
|
||||
|
||||
// soft voltage excitation here (E-field excite)
|
||||
for (unsigned int n=0;n<E_Exc_Count;++n)
|
||||
{
|
||||
exc_pos = (int)m_enginePtr->numTS - (int)m_enginePtr->Op->E_Exc_delay[n];
|
||||
exc_pos*= (exc_pos>0 && exc_pos<=(int)m_enginePtr->Op->ExciteLength);
|
||||
m_enginePtr->volt[m_enginePtr->Op->E_Exc_dir[n]][m_enginePtr->Op->E_Exc_index[0][n]][m_enginePtr->Op->E_Exc_index[1][n]][m_enginePtr->Op->E_Exc_index[2][n]] += m_enginePtr->Op->E_Exc_amp[n]*m_enginePtr->Op->ExciteSignal[exc_pos];
|
||||
}
|
||||
m_enginePtr->ApplyVoltageExcite();
|
||||
|
||||
// continue NS_Engine_Multithread::thread
|
||||
m_enginePtr->m_barrier2->wait();
|
||||
m_enginePtr->m_barrier2->wait(); // continue NS_Engine_Multithread::thread
|
||||
}
|
||||
|
||||
//DBG().cout() << "Thread e_excitation (" << boost::this_thread::get_id() << ") finished." << endl;
|
||||
|
|
|
@ -26,6 +26,12 @@
|
|||
#include <boost/fusion/container/list/list_fwd.hpp>
|
||||
#include <boost/fusion/include/list_fwd.hpp>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Winsock2.h> // for struct timeval
|
||||
#endif
|
||||
|
||||
#include <sys/time.h>
|
||||
|
||||
class Engine_Multithread;
|
||||
|
||||
namespace NS_Engine_Multithread {
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
#include <fstream>
|
||||
#include "operator.h"
|
||||
#include "operator_extension.h"
|
||||
#include "processfields.h"
|
||||
#include "tools/array_ops.h"
|
||||
#include "fparser.hh"
|
||||
|
@ -34,6 +35,9 @@ Operator::Operator()
|
|||
|
||||
Operator::~Operator()
|
||||
{
|
||||
for (size_t n=0;n<m_Op_exts.size();++n)
|
||||
delete m_Op_exts.at(n);
|
||||
m_Op_exts.clear();
|
||||
Reset();
|
||||
}
|
||||
|
||||
|
@ -102,6 +106,14 @@ unsigned int Operator::CalcNyquistNum(double fmax)
|
|||
return floor(T0/2/dT);
|
||||
}
|
||||
|
||||
string Operator::GetDirName(int ny) const
|
||||
{
|
||||
if (ny==0) return "x";
|
||||
if (ny==1) return "y";
|
||||
if (ny==2) return "z";
|
||||
return "";
|
||||
}
|
||||
|
||||
double Operator::GetMeshDelta(int n, const unsigned int* pos, bool dualMesh) const
|
||||
{
|
||||
if ((n<0) || (n>2)) return 0.0;
|
||||
|
@ -545,6 +557,10 @@ int Operator::CalcECOperator()
|
|||
}
|
||||
}
|
||||
|
||||
//all information available for extension... create now...
|
||||
for (size_t n=0;n<m_Op_exts.size();++n)
|
||||
m_Op_exts.at(n)->BuildExtension();
|
||||
|
||||
//cleanup
|
||||
for (int n=0;n<3;++n)
|
||||
{
|
||||
|
@ -1083,3 +1099,7 @@ bool Operator::CalcPEC()
|
|||
return true;
|
||||
}
|
||||
|
||||
void Operator::AddExtension(Operator_Extension* op_ext)
|
||||
{
|
||||
m_Op_exts.push_back(op_ext);
|
||||
}
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
|
||||
#define FDTD_FLOAT float
|
||||
|
||||
class Operator_Extension;
|
||||
|
||||
//! Abstract base-class for the FDTD-operator
|
||||
class Operator
|
||||
{
|
||||
|
@ -67,6 +69,9 @@ public:
|
|||
void DumpOperator2File(string filename);
|
||||
void DumpMaterial2File(string filename);
|
||||
|
||||
//! Get the name for the given direction: 0 -> x, 1 -> y, 2 -> z
|
||||
virtual string GetDirName(int ny) const;
|
||||
|
||||
virtual double GetGridDelta() const {return gridDelta;}
|
||||
//! Get the mesh delta times the grid delta for a 3D position
|
||||
virtual double GetMeshDelta(int n, const int* pos, bool dualMesh=false) const;
|
||||
|
@ -77,6 +82,10 @@ public:
|
|||
virtual double GetDiscLine(int n, unsigned int pos, bool dualMesh=false) const;
|
||||
virtual bool SnapToMesh(double* coord, unsigned int* uicoord, bool lower=false, bool* inside=NULL);
|
||||
|
||||
virtual void AddExtension(Operator_Extension* op_ext);
|
||||
virtual size_t GetNumberOfExtentions() const {return m_Op_exts.size();}
|
||||
virtual Operator_Extension* GetExtension(size_t index) const {return m_Op_exts.at(index);}
|
||||
|
||||
protected:
|
||||
//! use New() for creating a new Operator
|
||||
Operator();
|
||||
|
@ -123,6 +132,8 @@ protected:
|
|||
AdrOp* MainOp;
|
||||
AdrOp* DualOp;
|
||||
|
||||
vector<Operator_Extension*> m_Op_exts;
|
||||
|
||||
// engine/post-proc needs access
|
||||
public:
|
||||
//EC operator
|
||||
|
|
|
@ -68,13 +68,21 @@ inline unsigned int Operator_Cylinder::GetNumberOfLines(int ny) const
|
|||
return numLines[ny];
|
||||
}
|
||||
|
||||
double Operator_Cylinder::GetMeshDelta(int n, int* pos, bool dualMesh) const
|
||||
string Operator_Cylinder::GetDirName(int ny) const
|
||||
{
|
||||
if (ny==0) return "rho";
|
||||
if (ny==1) return "alpha";
|
||||
if (ny==2) return "z";
|
||||
return "";
|
||||
}
|
||||
|
||||
double Operator_Cylinder::GetMeshDelta(int n, const int* pos, bool dualMesh) const
|
||||
{
|
||||
double delta = Operator::GetMeshDelta(n,pos,dualMesh);
|
||||
if (delta==0) return delta;
|
||||
if (n==1)
|
||||
{
|
||||
return delta * GetDiscLine(n,pos[0],dualMesh);
|
||||
return delta * GetDiscLine(0,pos[0],dualMesh);
|
||||
}
|
||||
return delta;
|
||||
}
|
||||
|
@ -104,7 +112,10 @@ bool Operator_Cylinder::SetGeometryCSX(ContinuousStructure* geo)
|
|||
}
|
||||
else if (minmaxA>2*PI)
|
||||
{cerr << "Operator_Cylinder::SetGeometryCSX: Alpha Max-Min must not be larger than 2*PI!!!" << endl; Reset(); return false;}
|
||||
else CC_closedAlpha=false;
|
||||
else
|
||||
{
|
||||
CC_closedAlpha=false;
|
||||
}
|
||||
|
||||
if (discLines[0][0]<0)
|
||||
{cerr << "Operator_Cylinder::SetGeometryCSX: r<0 not allowed in Cylinder Coordinates!!!" << endl; Reset(); return false;}
|
||||
|
@ -123,7 +134,9 @@ int Operator_Cylinder::CalcECOperator()
|
|||
if (val)
|
||||
return val;
|
||||
|
||||
if (CC_R0_included==false)
|
||||
//if r=0 is not included -> obviously no special treatment for r=0
|
||||
//if alpha direction is not closed, PEC-BC at r=0 necessary and already set...
|
||||
if ((CC_R0_included==false) || (CC_closedAlpha==false))
|
||||
return val;
|
||||
|
||||
unsigned int pos[3];
|
||||
|
@ -133,16 +146,13 @@ int Operator_Cylinder::CalcECOperator()
|
|||
{
|
||||
double C=0;
|
||||
double G=0;
|
||||
for (pos[1]=0;pos[1]<numLines[1]-CC_closedAlpha;++pos[1])
|
||||
for (pos[1]=0;pos[1]<numLines[1]-1;++pos[1])
|
||||
{
|
||||
Calc_ECPos(2,pos,inEC);
|
||||
// if (pos[2]==0)
|
||||
// cerr << inEC[0] << endl;
|
||||
C+=inEC[0]*0.5;
|
||||
G+=inEC[1]*0.5;
|
||||
}
|
||||
if (pos[2]==0)
|
||||
cerr << C << " and " << G << endl;
|
||||
vv[2][0][0][pos[2]] = 1;
|
||||
vv_R0[pos[2]] = (1-dT*G/2/C)/(1+dT*G/2/C);
|
||||
vi_R0[pos[2]] = (dT/C)/(1+dT*G/2/C);
|
||||
}
|
||||
|
@ -173,12 +183,6 @@ inline void Operator_Cylinder::Calc_ECOperatorPos(int n, unsigned int* pos)
|
|||
ii[n][pos[0]][pos[1]][pos[2]] = 0;
|
||||
iv[n][pos[0]][pos[1]][pos[2]] = 0;
|
||||
}
|
||||
|
||||
if (CC_R0_included && (n==2) && (pos[0]==0))
|
||||
{
|
||||
vv[n][pos[0]][pos[1]][pos[2]] = 1;
|
||||
vi[n][pos[0]][pos[1]][pos[2]] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void Operator_Cylinder::ApplyElectricBC(bool* dirs)
|
||||
|
@ -190,9 +194,9 @@ void Operator_Cylinder::ApplyElectricBC(bool* dirs)
|
|||
}
|
||||
if (CC_R0_included)
|
||||
{
|
||||
dirs[2]=0; //no PEC in r_min directions...
|
||||
// no special treatment necessary
|
||||
// operator for z-direction at r=0 will be calculated and set separately
|
||||
}
|
||||
|
||||
Operator::ApplyElectricBC(dirs);
|
||||
}
|
||||
|
||||
|
@ -205,7 +209,7 @@ void Operator_Cylinder::ApplyMagneticBC(bool* dirs)
|
|||
}
|
||||
if (CC_R0_included)
|
||||
{
|
||||
dirs[2]=0; //no PMC in r_min directions...
|
||||
dirs[0]=0; //no PMC in r_min directions...
|
||||
}
|
||||
Operator::ApplyMagneticBC(dirs);
|
||||
}
|
||||
|
@ -348,7 +352,7 @@ bool Operator_Cylinder::Calc_ECPos(int n, unsigned int* pos, double* inEC)
|
|||
inEC[1] += 0;
|
||||
}
|
||||
|
||||
if (CC_R0_included && (n==1) && (coord[0]==0))
|
||||
if (CC_R0_included && (n==1) && (pos[0]==0))
|
||||
{
|
||||
inEC[0]=0;
|
||||
inEC[1]=0;
|
||||
|
|
|
@ -35,8 +35,11 @@ public:
|
|||
|
||||
virtual unsigned int GetNumberOfLines(int ny) const;
|
||||
|
||||
//! Get the name for the given direction: 0 -> rho, 1 -> alpha, 2 -> z
|
||||
virtual string GetDirName(int ny) const;
|
||||
|
||||
//! Get the mesh delta times the grid delta for a 3D position, including radius corrected alpha-mesh width
|
||||
virtual double GetMeshDelta(int n, int* pos, bool dualMesh=false) const;
|
||||
virtual double GetMeshDelta(int n, const int* pos, bool dualMesh=false) const;
|
||||
|
||||
bool GetClosedAlpha() const {return CC_closedAlpha;}
|
||||
bool GetR0Included() const {return CC_R0_included;}
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#include "operator_ext_mur_abc.h"
|
||||
#include "engine_ext_mur_abc.h"
|
||||
|
||||
#include "tools/array_ops.h"
|
||||
|
||||
Operator_Ext_Mur_ABC::Operator_Ext_Mur_ABC(Operator* op) : Operator_Extension(op)
|
||||
{
|
||||
m_Mur_Coeff = NULL;
|
||||
m_ny = -1;
|
||||
m_nyP = -1;
|
||||
m_nyPP = -1;
|
||||
m_LineNr = 0;
|
||||
m_LineNr_Shift = 0;
|
||||
m_Mur_Coeff = 0;
|
||||
}
|
||||
|
||||
Operator_Ext_Mur_ABC::~Operator_Ext_Mur_ABC()
|
||||
{
|
||||
}
|
||||
|
||||
void Operator_Ext_Mur_ABC::SetDirection(int ny, bool top_ny)
|
||||
{
|
||||
if ((ny<0) || (ny>2))
|
||||
return;
|
||||
m_ny = ny;
|
||||
m_nyP = (ny+1)%3;
|
||||
m_nyPP = (ny+2)%3;
|
||||
if (!top_ny)
|
||||
{
|
||||
m_LineNr = 0;
|
||||
m_LineNr_Shift = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_LineNr = m_Op->GetNumberOfLines(m_ny)-1;
|
||||
m_LineNr_Shift = m_Op->GetNumberOfLines(m_ny) - 2;
|
||||
}
|
||||
|
||||
m_numLines[0] = m_Op->GetNumberOfLines(m_nyP);
|
||||
m_numLines[1] = m_Op->GetNumberOfLines(m_nyPP);
|
||||
}
|
||||
|
||||
bool Operator_Ext_Mur_ABC::BuildExtension()
|
||||
{
|
||||
if (m_ny<0)
|
||||
{
|
||||
cerr << "Operator_Ext_Mur_ABC::BuildExtension: Warning, Extension not initialized! Use SetDirection!! Abort build!!" << endl;
|
||||
return false;
|
||||
}
|
||||
double dT = m_Op->GetTimestep();
|
||||
unsigned int pos[] = {0,0,0};
|
||||
pos[m_ny] = m_LineNr;
|
||||
double delta = fabs(m_Op->GetMeshDelta(m_ny,pos));
|
||||
m_Mur_Coeff = (__C0__ * dT - delta) / (__C0__ * dT + delta);
|
||||
// cerr << "Operator_Ext_Mur_ABC::BuildExtension(): " << m_Mur_Coeff << endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
Engine_Extension* Operator_Ext_Mur_ABC::CreateEngineExtention()
|
||||
{
|
||||
Engine_Ext_Mur_ABC* eng_ext = new Engine_Ext_Mur_ABC(this);
|
||||
return eng_ext;
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* 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 OPERATOR_EXT_MUR_ABC_H
|
||||
#define OPERATOR_EXT_MUR_ABC_H
|
||||
|
||||
#include "operator.h"
|
||||
#include "operator_extension.h"
|
||||
|
||||
class Operator_Ext_Mur_ABC : public Operator_Extension
|
||||
{
|
||||
friend class Engine_Ext_Mur_ABC;
|
||||
public:
|
||||
Operator_Ext_Mur_ABC(Operator* op);
|
||||
~Operator_Ext_Mur_ABC();
|
||||
|
||||
//! Define the direction of this ABC: ny=0,1,2 -> x,y,z and if at bottom_ny -> e.g. x=0 or x=end
|
||||
void SetDirection(int ny, bool top_ny);
|
||||
|
||||
virtual bool BuildExtension();
|
||||
|
||||
virtual Engine_Extension* CreateEngineExtention();
|
||||
|
||||
protected:
|
||||
int m_ny;
|
||||
int m_nyP,m_nyPP;
|
||||
unsigned int m_LineNr;
|
||||
int m_LineNr_Shift;
|
||||
|
||||
unsigned int m_numLines[2];
|
||||
|
||||
FDTD_FLOAT m_Mur_Coeff;
|
||||
};
|
||||
|
||||
#endif // OPERATOR_EXT_MUR_ABC_H
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#include "operator_extension.h"
|
||||
|
||||
#include "operator.h"
|
||||
|
||||
Operator_Extension::Operator_Extension(Operator* op)
|
||||
{
|
||||
m_Op = op;
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* 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 OPERATOR_EXTENSION_H
|
||||
#define OPERATOR_EXTENSION_H
|
||||
|
||||
class Operator;
|
||||
class Engine_Extension;
|
||||
|
||||
//! Abstract base-class for all operator extensions
|
||||
class Operator_Extension
|
||||
{
|
||||
public:
|
||||
virtual bool BuildExtension() {return true;}
|
||||
|
||||
virtual Engine_Extension* CreateEngineExtention() {return 0;}
|
||||
|
||||
protected:
|
||||
Operator_Extension(Operator* op);
|
||||
Operator* m_Op;
|
||||
};
|
||||
|
||||
#endif // OPERATOR_EXTENSION_H
|
|
@ -18,7 +18,7 @@
|
|||
#include "processfields.h"
|
||||
|
||||
#include <iomanip>
|
||||
#include "H5Cpp.h"
|
||||
#include <H5Cpp.h>
|
||||
|
||||
ProcessFields::ProcessFields(Operator* op, Engine* eng) : Processing(op, eng)
|
||||
{
|
||||
|
@ -51,7 +51,8 @@ ProcessFields::~ProcessFields()
|
|||
void ProcessFields::InitProcess()
|
||||
{
|
||||
if (Enabled==false) return;
|
||||
string names[] = {"x","y","z"};
|
||||
//get the correct direction names for all coordinate systems
|
||||
string names[] = {Op->GetDirName(0),Op->GetDirName(1),Op->GetDirName(2)};
|
||||
if (m_fileType==HDF5_FILETYPE)
|
||||
{
|
||||
unsigned int* NrLines;
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#define PROCESSFIELDS_H
|
||||
|
||||
#include "processing.h"
|
||||
#include "../tools/array_ops.h"
|
||||
#include "tools/array_ops.h"
|
||||
|
||||
class ProcessFields : public Processing
|
||||
{
|
||||
|
|
|
@ -1,4 +1,17 @@
|
|||
function PlotHDF5FieldData(file, PlotArgs)
|
||||
% function PlotHDF5FieldData(file, PlotArgs)
|
||||
%
|
||||
% e.g.
|
||||
% PlotArgs.slice = {0 [10 20] 0};
|
||||
% PlotArgs.pauseTime=0.01;
|
||||
% PlotArgs.component=2;
|
||||
% PlotArgs.Limit = 'auto';
|
||||
%
|
||||
% PlotHDF5FieldData('tmp/Et.h5',PlotArgs)
|
||||
%
|
||||
% openEMS matlab interface
|
||||
% -----------------------
|
||||
% author: Thorsten Liebig
|
||||
|
||||
component = PlotArgs.component;
|
||||
|
||||
|
@ -11,7 +24,11 @@ end
|
|||
mesh = ReadHDF5Mesh(file);
|
||||
fields = ReadHDF5FieldData(file);
|
||||
|
||||
[X Y Z] = meshgrid(double(mesh.lines{1}),double(mesh.lines{2}),double(mesh.lines{3}));
|
||||
if (mesh.type==0)
|
||||
[X Y Z] = meshgrid(double(mesh.lines{1}),double(mesh.lines{2}),double(mesh.lines{3}));
|
||||
else
|
||||
disp(['PlotHDF5FieldData:: Error: unknown mesh type ' num2str(mesh.type)]);
|
||||
end
|
||||
|
||||
max_amp = 0;
|
||||
|
||||
|
@ -46,14 +63,18 @@ for n=1:numel(Field)
|
|||
title(fields.names{n});
|
||||
%view(3)
|
||||
axis equal
|
||||
% if (isfield(PlotArgs,'zlim'))
|
||||
% if ~ischar(PlotArgs.zlim)
|
||||
% zlim(PlotArgs.zlim);
|
||||
% elseif strcmp(PlotArgs.zlim,'auto')
|
||||
% zlim([-max_amp*(component>0) max_amp]);
|
||||
% end
|
||||
% end
|
||||
%
|
||||
if (isfield(PlotArgs,'Limit'))
|
||||
if ~ischar(PlotArgs.Limit)
|
||||
caxis(PlotArgs.Limit);
|
||||
elseif strcmp(PlotArgs.Limit,'auto')
|
||||
if (component>0)
|
||||
caxis([-max_amp,max_amp]);
|
||||
else
|
||||
caxis([0,max_amp]);
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
drawnow
|
||||
pause(pauseT)
|
||||
end
|
|
@ -1,4 +1,13 @@
|
|||
function hdf_fielddata = ReadHDF5FieldData(file)
|
||||
% function hdf_fielddata = ReadHDF5FieldData(file)
|
||||
%
|
||||
% returns:
|
||||
% hdf_fielddata.names
|
||||
% hdf_fielddata.values
|
||||
%
|
||||
% openEMS matlab interface
|
||||
% -----------------------
|
||||
% author: Thorsten Liebig
|
||||
|
||||
info = hdf5info(file);
|
||||
|
||||
|
|
|
@ -1,4 +1,14 @@
|
|||
function hdf_mesh = ReadHDF5Mesh(file)
|
||||
% function hdf_mesh = ReadHDF5Mesh(file)
|
||||
%
|
||||
% returns:
|
||||
% hdf_mesh.type
|
||||
% hdf_mesh.names
|
||||
% hdf_mesh.lines
|
||||
%
|
||||
% openEMS matlab interface
|
||||
% -----------------------
|
||||
% author: Thorsten Liebig
|
||||
|
||||
info = hdf5info(file);
|
||||
|
||||
|
@ -14,3 +24,9 @@ hdf_mesh.names = names;
|
|||
for n=1:numel(names)
|
||||
hdf_mesh.lines{n} = hdf5read(file,names{n});
|
||||
end
|
||||
|
||||
if (strcmp(names{1},'/mesh/rho'))
|
||||
hdf_mesh.type=1;
|
||||
else
|
||||
hdf_mesh.type=0;
|
||||
end
|
|
@ -1,4 +1,16 @@
|
|||
function UI = ReadUI(files, path)
|
||||
% function UI = ReadUI(files, path)
|
||||
%
|
||||
% read current and voltages from multiple files found in path
|
||||
%
|
||||
% returns voltages/currents in time and frequency-domain
|
||||
%
|
||||
% e.g.
|
||||
% UI = ReadUI({'ut1_1','ut1_2','it1'},'tmp/');
|
||||
%
|
||||
% openEMS matlab interface
|
||||
% -----------------------
|
||||
% author: Thorsten Liebig
|
||||
|
||||
if (nargin<2)
|
||||
path ='';
|
||||
|
|
|
@ -3,6 +3,10 @@ function FDTD = SetBoundaryCond(FDTD,BC)
|
|||
%
|
||||
% BC = [xmin xmax ymin ymax zmin zmax];
|
||||
% ?min/?max: 0=PEC 1=PMC
|
||||
%
|
||||
% openEMS matlab interface
|
||||
% -----------------------
|
||||
% author: Thorsten Liebig
|
||||
|
||||
FDTD.BoundaryCond.ATTRIBUTE.xmin=BC(1);
|
||||
FDTD.BoundaryCond.ATTRIBUTE.xmax=BC(2);
|
||||
|
|
|
@ -1,4 +1,19 @@
|
|||
function FDTD = SetCustomExcite(FDTD,f0,funcStr);
|
||||
function FDTD = SetCustomExcite(FDTD,f0,funcStr)
|
||||
% function FDTD = SetCustomExcite(FDTD,f0,funcStr)
|
||||
%
|
||||
% f0 : nyquist rate
|
||||
% funcStr : string desribing the excitation function e(t)
|
||||
%
|
||||
% see also SetSinusExcite SetGaussExcite
|
||||
%
|
||||
% e.g for a ramped sinus excite...
|
||||
% T = 1/f0;
|
||||
% FDTD = SetCustomExcite(FDTD,1e9,..
|
||||
% [ '(1-exp(-1*(t/' num2str(T) ')^2) ) * sin(2*pi*' num2str(f0) '*t)' ]);
|
||||
%
|
||||
% openEMS matlab interface
|
||||
% -----------------------
|
||||
% author: Thorsten Liebig
|
||||
|
||||
FDTD.Excitation.ATTRIBUTE.Type=10;
|
||||
FDTD.Excitation.ATTRIBUTE.f0=f0;
|
||||
|
|
|
@ -1,4 +1,16 @@
|
|||
function FDTD = SetGaussExcite(FDTD,f0,fc);
|
||||
function FDTD = SetGaussExcite(FDTD,f0,fc)
|
||||
% function FDTD = SetSinusExcite(FDTD,f0,fc);
|
||||
%
|
||||
% f0 : center frequency
|
||||
% fc : 3dB cutoff frequency --> bandwidth is 2*fc
|
||||
%
|
||||
% see also SetSinusExcite SetCustomExcite
|
||||
%
|
||||
% e.g FDTD = SetGaussExcite(FDTD,1e9,1e8);
|
||||
%
|
||||
% openEMS matlab interface
|
||||
% -----------------------
|
||||
% author: Thorsten Liebig
|
||||
|
||||
FDTD.Excitation.ATTRIBUTE.Type=0;
|
||||
FDTD.Excitation.ATTRIBUTE.f0=f0;
|
||||
|
|
|
@ -1,4 +1,13 @@
|
|||
function FDTD = SetGaussExcite(FDTD,f0);
|
||||
function FDTD = SetSinusExcite(FDTD,f0)
|
||||
% function FDTD = SetSinusExcite(FDTD,f0)
|
||||
%
|
||||
% see also SetGaussExcite SetCustomExcite
|
||||
%
|
||||
% e.g FDTD = SetSinusExcite(FDTD,1e9);
|
||||
%
|
||||
% openEMS matlab interface
|
||||
% -----------------------
|
||||
% author: Thorsten Liebig
|
||||
|
||||
FDTD.Excitation.ATTRIBUTE.Type=1;
|
||||
FDTD.Excitation.ATTRIBUTE.f0=f0;
|
|
@ -1,4 +1,9 @@
|
|||
function WriteOpenEMS(filename, FDTD, CSX)
|
||||
% function WriteOpenEMS(filename, FDTD, CSX)
|
||||
%
|
||||
% openEMS matlab interface
|
||||
% -----------------------
|
||||
% author: Thorsten Liebig
|
||||
|
||||
openEMS.FDTD = FDTD;
|
||||
openEMS.ContinuousStructure = CSX;
|
||||
|
|
|
@ -2,6 +2,7 @@ close all;
|
|||
clear all;
|
||||
clc
|
||||
|
||||
%% setup the simulation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
abs_length = 500;
|
||||
length = 5000;
|
||||
unit = 1e-3;
|
||||
|
@ -27,6 +28,7 @@ func_Ea = [ num2str(1/kc) '*sin(a)*0.5*(j0(' num2str(kc) '*rho)-jn(2,' num2str
|
|||
func_Ex = [func_Er '*cos(a) - ' func_Ea '*sin(a)'];
|
||||
func_Ey = [func_Er '*sin(a) + ' func_Ea '*cos(a)'];
|
||||
|
||||
%% define file pathes and openEMS options %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
openEMS_Path = [pwd() '/../../']
|
||||
openEMS_opts = '';
|
||||
% openEMS_opts = [openEMS_opts ' --disable-dumps'];
|
||||
|
@ -39,14 +41,14 @@ Sim_CSX = 'Circ_WG.xml';
|
|||
|
||||
mkdir(Sim_Path);
|
||||
|
||||
%setup FDTD parameter
|
||||
%% setup FDTD parameter & excitation function %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
FDTD = InitFDTD(1000,1e-6,'OverSampling',5);
|
||||
T = 1/f0;
|
||||
FDTD = SetCustomExcite(FDTD,f0,[ '(1-exp(-1*(t/' num2str(T) ')^2) ) * sin(2*pi*' num2str(f0) '*t)' ]);
|
||||
BC = [1 1 1 1 1 1] * 0;
|
||||
FDTD = SetBoundaryCond(FDTD,BC);
|
||||
|
||||
%setup CSXCAD geometry
|
||||
%% setup CSXCAD geometry & mesh %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
CSX = InitCSX();
|
||||
mesh.x = -mesh_res(1)/2-rad:mesh_res(1):rad+mesh_res(1)/2;
|
||||
mesh.y = -mesh_res(2)/2-rad:mesh_res(2):rad+mesh_res(2)/2;
|
||||
|
@ -56,7 +58,7 @@ CSX = DefineRectGrid(CSX, 1e-3,mesh);
|
|||
start = [0,0,0];
|
||||
stop = [0,0,length];
|
||||
|
||||
%%fake pml
|
||||
%%% fake pml
|
||||
finalKappa = 0.3/abs_length^4;
|
||||
finalSigma = finalKappa*MUE0/EPS0;
|
||||
CSX = AddMaterial(CSX,'pml');
|
||||
|
@ -83,7 +85,7 @@ weight{3} = 0;
|
|||
CSX = SetExcitationWeight(CSX, 'excite', weight );
|
||||
CSX = AddCylinder(CSX,'excite', 5 ,[0 0 -0.1],[0 0 0.1],rad);
|
||||
|
||||
%dump
|
||||
%% define dump boxes... %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
CSX = AddDump(CSX,'Et','SubSampling','2,2,4','FileType',1,'DumpMode',2);
|
||||
start = [mesh.x(1) , mesh.y(1) , mesh.z(1)];
|
||||
stop = [mesh.x(end) , mesh.y(end) , mesh.z(end)];
|
||||
|
@ -102,21 +104,22 @@ CSX = AddBox(CSX,'Et',0 , start,stop);
|
|||
% stop = [mesh.x(end) , mesh.y(end) , length/2];
|
||||
% CSX = AddBox(CSX,'Exy',0 , start,stop);
|
||||
|
||||
%% define voltage calc boxes %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%voltage calc
|
||||
CSX = AddProbe(CSX,'ut1',0);
|
||||
start = [ -rad 0 0/2 ];stop = [ rad 0 0/2 ];
|
||||
CSX = AddBox(CSX,'ut1', 0 ,start,stop);
|
||||
%
|
||||
% %current calc
|
||||
% CSX = AddProbe(CSX,'it1',1);
|
||||
% mid = 0.5*(coax_rad_i+coax_rad_ai);
|
||||
% start = [ -mid -mid length/2 ];stop = [ mid mid length/2 ];
|
||||
% CSX = AddBox(CSX,'it1', 0 ,start,stop);
|
||||
|
||||
%Write openEMS compatoble xml-file
|
||||
%current calc
|
||||
CSX = AddProbe(CSX,'it1',1);
|
||||
mid = 0.5*(coax_rad_i+coax_rad_ai);
|
||||
start = [ -mid -mid length/2 ];stop = [ mid mid length/2 ];
|
||||
CSX = AddBox(CSX,'it1', 0 ,start,stop);
|
||||
|
||||
%% Write openEMS compatoble xml-file %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
WriteOpenEMS([Sim_Path '/' Sim_CSX],FDTD,CSX);
|
||||
|
||||
%cd to working dir and run openEMS
|
||||
%% cd to working dir and run openEMS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
savePath = pwd();
|
||||
cd(Sim_Path); %cd to working dir
|
||||
command = [openEMS_Path 'openEMS.sh ' Sim_CSX ' ' openEMS_opts];
|
||||
|
@ -124,6 +127,7 @@ disp(command);
|
|||
system(command)
|
||||
cd(savePath);
|
||||
|
||||
%% do the plots %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
UI = ReadUI('ut1','tmp/');
|
||||
plot(UI.TD{1}.t,UI.TD{1}.val);
|
||||
grid on;
|
||||
|
|
|
@ -2,14 +2,16 @@ close all;
|
|||
clear all;
|
||||
clc
|
||||
|
||||
%% setup the simulation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
abs_length = 500;
|
||||
length = 5000;
|
||||
length = 10000;
|
||||
unit = 1e-3;
|
||||
rad = 300;
|
||||
mesh_max = 15;
|
||||
N_alpha = ceil(rad * 2*pi / mesh_max);
|
||||
N_alpha = ceil(rad * pi / mesh_max) * 2;
|
||||
mesh_res = [mesh_max 2*pi/N_alpha mesh_max];
|
||||
|
||||
do_Half_Waveguide = 1;
|
||||
|
||||
EPS0 = 8.85418781762e-12;
|
||||
MUE0 = 1.256637062e-6;
|
||||
|
@ -24,9 +26,10 @@ fc = C0*kc/2/pi
|
|||
beta = sqrt(k^2 - kc^2);
|
||||
|
||||
kc = kc*unit;
|
||||
func_Er = [ num2str(-1/kc^2) '/rho*cos(a)*j1(' num2str(kc) '*rho)'];
|
||||
func_Ea = [ num2str(1/kc) '*sin(a)*0.5*(j0(' num2str(kc) '*rho)-jn(2,' num2str(kc) '*rho))'];
|
||||
func_Er = [ num2str(-1/kc^2,15) '/rho*cos(a)*j1(' num2str(kc,15) '*rho)'];
|
||||
func_Ea = [ num2str(1/kc,15) '*sin(a)*0.5*(j0(' num2str(kc,15) '*rho)-jn(2,' num2str(kc,15) '*rho))'];
|
||||
|
||||
%% define file pathes and openEMS options %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
openEMS_Path = [pwd() '/../../']
|
||||
openEMS_opts = '';
|
||||
% openEMS_opts = [openEMS_opts ' --disable-dumps'];
|
||||
|
@ -34,29 +37,38 @@ openEMS_opts = '';
|
|||
% openEMS_opts = [openEMS_opts ' --debug-operator'];
|
||||
% openEMS_opts = [openEMS_opts ' --engine=multithreaded'];
|
||||
|
||||
Sim_Path = 'tmp';
|
||||
if (do_Half_Waveguide)
|
||||
Sim_Path = 'tmp_half_CWG_CC';
|
||||
else
|
||||
Sim_Path = 'tmp_full_CWG_CC';
|
||||
end
|
||||
Sim_CSX = 'Circ_WG_CC.xml';
|
||||
|
||||
mkdir(Sim_Path);
|
||||
|
||||
%setup FDTD parameter
|
||||
%% setup FDTD parameter & excitation function %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
FDTD = InitCylindricalFDTD(1e5,1e-5,'OverSampling',10);
|
||||
T = 1/f0;
|
||||
FDTD = SetCustomExcite(FDTD,f0,[ '(1-exp(-1*(t/' num2str(T) ')^2) ) * sin(2*pi*' num2str(f0) '*t)' ]);
|
||||
% T = 1/f0;
|
||||
% FDTD = SetCustomExcite(FDTD,f0,[ '(1-exp(-1*(t/' num2str(T) ')^2) ) * sin(2*pi*' num2str(f0) '*t)' ]);
|
||||
FDTD = SetSinusExcite(FDTD,f0);
|
||||
BC = [0 0 0 0 0 0];
|
||||
FDTD = SetBoundaryCond(FDTD,BC);
|
||||
|
||||
%setup CSXCAD geometry
|
||||
%% setup CSXCAD geometry & mesh %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
CSX = InitCSX();
|
||||
mesh.x = [0 2*mesh_res(1):mesh_res(1):rad];
|
||||
mesh.y = linspace(-pi,pi,N_alpha);
|
||||
mesh.x = 0:mesh_res(1):rad;
|
||||
if (do_Half_Waveguide)
|
||||
mesh.y = linspace(-pi/2,pi/2,N_alpha/2);
|
||||
else
|
||||
mesh.y = linspace(-pi,pi,N_alpha)+pi/2;
|
||||
end
|
||||
y_delta = mesh.y(2) - mesh.y(1);
|
||||
mesh.z = 0 : mesh_res(3) : length;
|
||||
CSX = DefineRectGrid(CSX, 1e-3,mesh);
|
||||
|
||||
start = [0 mesh.y(1) length-abs_length];
|
||||
stop = [rad mesh.y(end) length];
|
||||
|
||||
%%fake pml
|
||||
%% fake pml %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
start = [0 mesh.y(1)-y_delta length-abs_length];
|
||||
stop = [rad*1.2 mesh.y(end)+y_delta length];
|
||||
finalKappa = 0.3/abs_length^4;
|
||||
finalSigma = finalKappa*MUE0/EPS0;
|
||||
CSX = AddMaterial(CSX,'pml');
|
||||
|
@ -66,27 +78,31 @@ CSX = SetMaterialWeight(CSX,'pml','Kappa',['pow(abs(z)-' num2str(length-abs_leng
|
|||
CSX = SetMaterialWeight(CSX,'pml','Sigma',['pow(abs(z)-' num2str(length-abs_length) ',4)']);
|
||||
CSX = AddBox(CSX,'pml',0 ,start,stop);
|
||||
|
||||
%% apply the excitation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
CSX = AddExcitation(CSX,'excite',0,[1 1 0]);
|
||||
weight{1} = func_Er;
|
||||
weight{2} = func_Ea;
|
||||
weight{3} = 0;
|
||||
CSX = SetExcitationWeight(CSX, 'excite', weight );
|
||||
start(3)=-5;
|
||||
stop(3)=5;
|
||||
start(3)=-.5;
|
||||
stop(3)=0.5;
|
||||
CSX = AddBox(CSX,'excite', 5 ,start,stop);
|
||||
|
||||
%dump
|
||||
CSX = AddDump(CSX,'Et','FileType',0,'DumpMode',0);
|
||||
start = [mesh.x(1) ,0 , mesh.z(1)];
|
||||
stop = [mesh.x(end) , 0 , mesh.z(end)];
|
||||
%% define dump boxes... %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
CSX = AddDump(CSX,'Et','FileType',1,'DumpMode',0,'SubSampling','1,1,5');
|
||||
start = [mesh.x(1) , mesh.y(1)-y_delta , 0];
|
||||
stop = [mesh.x(end) , mesh.y(end)+y_delta , length];
|
||||
CSX = AddBox(CSX,'Et',0 , start,stop);
|
||||
|
||||
CSX = AddDump(CSX,'Ht','DumpType',1,'FileType',0,'DumpMode',0);
|
||||
start = [mesh.x(1) ,0 , mesh.z(1)];
|
||||
stop = [mesh.x(end) , 0 , mesh.z(end)];
|
||||
CSX = AddDump(CSX,'Ht','FileType',1,'DumpType',1,'DumpMode',0,'SubSampling','1,1,5');
|
||||
CSX = AddBox(CSX,'Ht',0 , start,stop);
|
||||
|
||||
%voltage calc
|
||||
CSX = AddDump(CSX,'Et_rz_','FileType',0,'DumpMode',2,'SubSampling','1,1,5');
|
||||
start = [mesh.x(1) , 0 , 0];
|
||||
stop = [mesh.x(end) , 0 , length];
|
||||
CSX = AddBox(CSX,'Et_rz_',0 , start,stop);
|
||||
|
||||
%% define voltage calc boxes %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
CSX = AddProbe(CSX,'ut_exc',0);
|
||||
start = [ 0 0 0 ];stop = [ rad 0 0 ];
|
||||
CSX = AddBox(CSX,'ut_exc', 0 ,start,stop);
|
||||
|
@ -95,10 +111,10 @@ CSX = AddProbe(CSX,'ut_1',0);
|
|||
start = [ 0 0 length/2 ];stop = [ rad 0 length/2 ];
|
||||
CSX = AddBox(CSX,'ut_1', 0 ,start,stop);
|
||||
|
||||
%Write openEMS compatoble xml-file
|
||||
%% Write openEMS compatoble xml-file %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
WriteOpenEMS([Sim_Path '/' Sim_CSX],FDTD,CSX);
|
||||
|
||||
%cd to working dir and run openEMS
|
||||
%% cd to working dir and run openEMS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
savePath = pwd();
|
||||
cd(Sim_Path); %cd to working dir
|
||||
command = [openEMS_Path 'openEMS.sh ' Sim_CSX ' ' openEMS_opts];
|
||||
|
@ -106,16 +122,35 @@ disp(command);
|
|||
system(command)
|
||||
cd(savePath);
|
||||
|
||||
UI = ReadUI('ut_1','tmp/');
|
||||
%% do the plots %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
UI = ReadUI('ut_1',[Sim_Path '/']);
|
||||
plot(UI.TD{1}.t,UI.TD{1}.val);
|
||||
grid on;
|
||||
|
||||
% plotting
|
||||
% if exist('tmp/Et.h5','file')
|
||||
% PlotArgs.slice = {mesh.x(round(end/2)) mesh.y(round(end/2)) mesh.z(round(end/2))};
|
||||
% PlotArgs.pauseTime=0.1;
|
||||
% PlotArgs.component=0;
|
||||
% PlotArgs.zlim='auto';
|
||||
%
|
||||
% PlotHDF5FieldData('tmp/Et.h5',PlotArgs)
|
||||
% end
|
||||
file = [Sim_Path '/Et.h5'];
|
||||
z_planes = 1;
|
||||
timestep = 10;
|
||||
for z =z_planes
|
||||
figure
|
||||
if exist(file,'file')
|
||||
mesh = ReadHDF5Mesh(file);
|
||||
fields = ReadHDF5FieldData(file);
|
||||
|
||||
[ALPHA RHO] = meshgrid(double(mesh.lines{1}),double(mesh.lines{2}));
|
||||
X = RHO.*cos(ALPHA);
|
||||
Y = RHO.*sin(ALPHA);
|
||||
|
||||
Er = double( fields.values{timestep}(:,:,z,1) );
|
||||
Ea = double( fields.values{timestep}(:,:,z,2) );
|
||||
Ez = double( fields.values{timestep}(:,:,z,3) );
|
||||
|
||||
Ex = Er.*cos(ALPHA) - Ea.*sin(ALPHA);
|
||||
Ey = Er.*sin(ALPHA) + Ea.*cos(ALPHA);
|
||||
|
||||
quiver(X,Y,Ex,Ey)
|
||||
axis equal
|
||||
title(['z : ' num2str(mesh.lines{2}(z)) ' ts: ' int2str(n)] );
|
||||
Ex(10,5)
|
||||
pause(1)
|
||||
end
|
||||
end
|
|
@ -2,6 +2,7 @@ close all;
|
|||
clear all;
|
||||
clc
|
||||
|
||||
%% setup the simulation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
abs_length = 250;
|
||||
length = 1000;
|
||||
coax_rad_i = 100;
|
||||
|
@ -11,10 +12,16 @@ mesh_res = [5 5 5];
|
|||
|
||||
EPS0 = 8.85418781762e-12;
|
||||
MUE0 = 1.256637062e-6;
|
||||
C0 = 1/sqrt(EPS0*MUE0);
|
||||
Z0 = sqrt(MUE0/EPS0);
|
||||
|
||||
f0 = 0.5e9;
|
||||
epsR = 1;
|
||||
|
||||
%% define file pathes and openEMS options %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
openEMS_Path = [pwd() '/../../']
|
||||
openEMS_opts = '';
|
||||
% openEMS_opts = [openEMS_opts ' --disable-dumps'];
|
||||
openEMS_opts = [openEMS_opts ' --disable-dumps'];
|
||||
% openEMS_opts = [openEMS_opts ' --debug-material'];
|
||||
|
||||
Sim_Path = 'tmp';
|
||||
|
@ -22,24 +29,20 @@ Sim_CSX = 'coax.xml';
|
|||
|
||||
mkdir(Sim_Path);
|
||||
|
||||
%setup FDTD parameter
|
||||
FDTD = InitFDTD(5e5,1e-6);
|
||||
FDTD = SetGaussExcite(FDTD,0.5e9,0.5e9);
|
||||
%% setup FDTD parameter & excitation function %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
FDTD = InitFDTD(5e5,1e-5);
|
||||
FDTD = SetGaussExcite(FDTD,f0,f0);
|
||||
BC = [1 1 1 1 1 1] * 0;
|
||||
FDTD = SetBoundaryCond(FDTD,BC);
|
||||
|
||||
%setup CSXCAD geometry
|
||||
%% setup CSXCAD geometry & mesh %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
CSX = InitCSX();
|
||||
mesh.x = -2.5*mesh_res(1)-coax_rad_aa : mesh_res(1) : coax_rad_aa+2.5*mesh_res(1);
|
||||
mesh.y = mesh.x;
|
||||
mesh.z = 0 : mesh_res(3) : length;
|
||||
CSX = DefineRectGrid(CSX, 1e-3,mesh);
|
||||
|
||||
%create copper helix and feed lines...
|
||||
CSX = AddMaterial(CSX,'copper');
|
||||
CSX = SetMaterialProperty(CSX,'copper','Kappa',56e6);
|
||||
|
||||
%%%fake pml
|
||||
%% fake pml %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
finalKappa = 0.3/abs_length^4;
|
||||
finalSigma = finalKappa*MUE0/EPS0;
|
||||
CSX = AddMaterial(CSX,'pml');
|
||||
|
@ -49,11 +52,15 @@ CSX = SetMaterialWeight(CSX,'pml','Kappa',['pow(abs(z)-' num2str(length-abs_leng
|
|||
CSX = SetMaterialWeight(CSX,'pml','Sigma',['pow(abs(z)-' num2str(length-abs_length) ',4)']);
|
||||
|
||||
%%% coax
|
||||
CSX = AddMaterial(CSX,'copper');
|
||||
CSX = SetMaterialProperty(CSX,'copper','Kappa',56e6);
|
||||
start = [0, 0 , 0];stop = [0, 0 , length];
|
||||
CSX = AddCylinder(CSX,'copper',0 ,start,stop,coax_rad_i);
|
||||
CSX = AddCylindricalShell(CSX,'copper',0 ,start,stop,0.5*(coax_rad_aa+coax_rad_ai),(coax_rad_aa-coax_rad_ai));
|
||||
start(3) = length-abs_length;
|
||||
CSX = AddCylindricalShell(CSX,'pml',0 ,start,stop,0.5*(coax_rad_i+coax_rad_ai),(coax_rad_ai-coax_rad_i));
|
||||
|
||||
%% apply the excitation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
start(3) = 0; stop(3)=mesh_res(1)/2;
|
||||
CSX = AddExcitation(CSX,'excite',0,[1 1 0]);
|
||||
weight{1} = '(x)/(x*x+y*y)';
|
||||
|
@ -62,7 +69,7 @@ weight{3} = 0;
|
|||
CSX = SetExcitationWeight(CSX, 'excite', weight );
|
||||
CSX = AddCylindricalShell(CSX,'excite',0 ,start,stop,0.5*(coax_rad_i+coax_rad_ai),(coax_rad_ai-coax_rad_i));
|
||||
|
||||
%dump
|
||||
%% define dump boxes... %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
CSX = AddDump(CSX,'Et_','DumpMode',2);
|
||||
start = [mesh.x(1) , 0 , mesh.z(1)];
|
||||
stop = [mesh.x(end) , 0 , mesh.z(end)];
|
||||
|
@ -72,9 +79,12 @@ CSX = AddDump(CSX,'Ht_','DumpType',1,'DumpMode',2);
|
|||
CSX = AddBox(CSX,'Ht_',0,start,stop);
|
||||
|
||||
%voltage calc
|
||||
CSX = AddProbe(CSX,'ut1',0);
|
||||
CSX = AddProbe(CSX,'ut1_1',0);
|
||||
start = [ coax_rad_i 0 length/2 ];stop = [ coax_rad_ai 0 length/2 ];
|
||||
CSX = AddBox(CSX,'ut1', 0 ,start,stop);
|
||||
CSX = AddBox(CSX,'ut1_1', 0 ,start,stop);
|
||||
CSX = AddProbe(CSX,'ut1_2',0);
|
||||
start = [ coax_rad_i 0 length/2+mesh_res(3) ];stop = [ coax_rad_ai 0 length/2+mesh_res(3) ];
|
||||
CSX = AddBox(CSX,'ut1_2', 0 ,start,stop);
|
||||
|
||||
%current calc
|
||||
CSX = AddProbe(CSX,'it1',1);
|
||||
|
@ -85,7 +95,7 @@ CSX = AddBox(CSX,'it1', 0 ,start,stop);
|
|||
%Write openEMS compatoble xml-file
|
||||
WriteOpenEMS([Sim_Path '/' Sim_CSX],FDTD,CSX);
|
||||
|
||||
%cd to working dir and run openEMS
|
||||
%% cd to working dir and run openEMS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
savePath = pwd();
|
||||
cd(Sim_Path); %cd to working dir
|
||||
command = [openEMS_Path 'openEMS.sh ' Sim_CSX ' ' openEMS_opts];
|
||||
|
@ -93,3 +103,20 @@ disp(command);
|
|||
system(command)
|
||||
cd(savePath);
|
||||
|
||||
%% postproc & do the plots %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
UI = ReadUI({'ut1_1','ut1_2','it1'},'tmp/');
|
||||
u_f = (UI.FD{1}.val + UI.FD{2}.val)/2; %averaging voltages to fit current
|
||||
i_f = UI.FD{3}.val;
|
||||
|
||||
delta_t = UI.TD{3}.t(1) - UI.TD{1}.t(1); % half time-step (s)
|
||||
i_f2 = i_f .* exp(-1i*2*pi*UI.FD{1}.f*delta_t); % compensate half time-step advance of H-field
|
||||
|
||||
ZL = Z0/2/pi/sqrt(epsR)*log(coax_rad_ai/coax_rad_i); %analytic line-impedance of a coax
|
||||
plot(UI.FD{1}.f,ZL*ones(size(u_f)),'g');
|
||||
hold on;
|
||||
grid on;
|
||||
Z = u_f./i_f2;
|
||||
plot(UI.FD{1}.f,real(Z),'Linewidth',2);
|
||||
plot(UI.FD{1}.f,imag(Z),'r','Linewidth',2);
|
||||
xlim([0 2*f0]);
|
||||
legend('Z_L','\Re\{Z\}','\Im\{Z\}','Location','Best');
|
||||
|
|
|
@ -2,6 +2,7 @@ close all;
|
|||
clear all;
|
||||
clc
|
||||
|
||||
%% setup the simulation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
EPS0 = 8.85418781762e-12;
|
||||
MUE0 = 1.256637062e-6;
|
||||
C0 = 1/sqrt(EPS0*MUE0);
|
||||
|
@ -20,6 +21,7 @@ max_alpha = max_mesh;
|
|||
N_alpha = ceil(rad_a * 2*pi / max_alpha);
|
||||
mesh_res = [max_mesh 2*pi/N_alpha max_mesh];
|
||||
|
||||
%% define file pathes and openEMS options %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
openEMS_Path = [pwd() '/../../'];
|
||||
openEMS_opts = '';
|
||||
openEMS_opts = [openEMS_opts ' --disable-dumps'];
|
||||
|
@ -30,13 +32,13 @@ Sim_CSX = 'coax.xml';
|
|||
|
||||
mkdir(Sim_Path);
|
||||
|
||||
%setup FDTD parameter
|
||||
%% setup FDTD parameter & excitation function %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
FDTD = InitCylindricalFDTD(1e5,1e-5,'OverSampling',10);
|
||||
FDTD = SetGaussExcite(FDTD,f0,f0);
|
||||
BC = [0 0 1 1 0 0];
|
||||
FDTD = SetBoundaryCond(FDTD,BC);
|
||||
|
||||
%setup CSXCAD geometry
|
||||
%% setup CSXCAD geometry & mesh %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
CSX = InitCSX();
|
||||
mesh.x = rad_i : mesh_res(1) : rad_a;
|
||||
mesh.y = linspace(0,2*pi,N_alpha);
|
||||
|
@ -44,7 +46,7 @@ mesh.y = linspace(0,2*pi,N_alpha);
|
|||
mesh.z = 0 : mesh_res(3) : length;
|
||||
CSX = DefineRectGrid(CSX, 1e-3,mesh);
|
||||
|
||||
%%%fake pml
|
||||
%% fake pml %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
finalKappa = 0.3/abs_length^4;
|
||||
finalSigma = finalKappa*MUE0/EPS0/epsR;
|
||||
CSX = AddMaterial(CSX,'pml');
|
||||
|
@ -67,6 +69,7 @@ CSX = AddBox(CSX,'fill',0 ,start,stop);
|
|||
start = [rad_i mesh.y(1) 0];
|
||||
stop = [rad_a mesh.y(end) 0];
|
||||
|
||||
%% apply the excitation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
CSX = AddExcitation(CSX,'excite',0,[1 0 0]);
|
||||
weight{1} = '1/rho';
|
||||
weight{2} = 0;
|
||||
|
@ -74,7 +77,7 @@ weight{3} = 0;
|
|||
CSX = SetExcitationWeight(CSX, 'excite', weight );
|
||||
CSX = AddBox(CSX,'excite',0 ,start,stop);
|
||||
|
||||
%dump
|
||||
%% define dump boxes... %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
CSX = AddDump(CSX,'Et_','DumpMode',0);
|
||||
start = [mesh.x(1) , 0 , mesh.z(1)];
|
||||
stop = [mesh.x(end) , 0 , mesh.z(end)];
|
||||
|
@ -101,7 +104,7 @@ CSX = AddBox(CSX,'it1', 0 ,start,stop);
|
|||
%Write openEMS compatoble xml-file
|
||||
WriteOpenEMS([Sim_Path '/' Sim_CSX],FDTD,CSX);
|
||||
|
||||
%cd to working dir and run openEMS
|
||||
%% cd to working dir and run openEMS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
savePath = pwd();
|
||||
cd(Sim_Path); %cd to working dir
|
||||
command = [openEMS_Path 'openEMS.sh ' Sim_CSX ' ' openEMS_opts];
|
||||
|
@ -109,6 +112,7 @@ disp(command);
|
|||
system(command)
|
||||
cd(savePath);
|
||||
|
||||
%% postproc & do the plots %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
UI = ReadUI({'ut1_1','ut1_2','it1'},'tmp/');
|
||||
u_f = (UI.FD{1}.val + UI.FD{2}.val)/2; %averaging voltages to fit current
|
||||
i_f = UI.FD{3}.val;
|
||||
|
|
|
@ -2,6 +2,7 @@ close all;
|
|||
clear;
|
||||
clc
|
||||
|
||||
%% setup the simulation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
feed_length=10;
|
||||
wire_rad = sqrt(1.4/pi);
|
||||
mesh_size = wire_rad;
|
||||
|
@ -13,12 +14,14 @@ port_length = mesh_size; %coil_length/2;
|
|||
port_resist = 1000;
|
||||
|
||||
f_max = 100e6;
|
||||
f_excite = 1e9;
|
||||
f_excite = 300e6;
|
||||
|
||||
%% define file pathes and openEMS options %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
openEMS_Path = [pwd() '/../../']
|
||||
openEMS_opts = '';
|
||||
% openEMS_opts = [openEMS_opts ' --disable-dumps'];
|
||||
% openEMS_opts = [openEMS_opts ' --debug-material'];
|
||||
openEMS_opts = [openEMS_opts ' --debug-material'];
|
||||
openEMS_opts = [openEMS_opts ' --debug-boxes'];
|
||||
% openEMS_opts = [openEMS_opts ' --debug-operator'];
|
||||
|
||||
Sim_Path = 'tmp';
|
||||
|
@ -27,16 +30,16 @@ Sim_CSX = 'helix.xml';
|
|||
rmdir(Sim_Path,'s');
|
||||
mkdir(Sim_Path);
|
||||
|
||||
%setup FDTD parameter
|
||||
FDTD = InitFDTD(5e5,1e-6);
|
||||
%% setup FDTD parameter & excitation function %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
FDTD = InitFDTD(30000,1e-6);
|
||||
FDTD = SetGaussExcite(FDTD,f_excite/2,f_excite/2);
|
||||
BC = [1 1 1 1 1 1];
|
||||
FDTD = SetBoundaryCond(FDTD,BC);
|
||||
|
||||
%% setup CSXCAD geometry & mesh %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
add_Lines = mesh_size * 1.5.^(1:10);
|
||||
add_Lines = add_Lines(find(add_Lines<(3e8/f_excite)/10*1e3));
|
||||
|
||||
%setup CSXCAD geometry
|
||||
CSX = InitCSX();
|
||||
mesh.x = -coil_rad-mesh_size : mesh_size : coil_rad+mesh_size+feed_length;
|
||||
mesh.x = [mesh.x(1)-add_Lines mesh.x mesh.x(end)+add_Lines ];
|
||||
|
@ -46,11 +49,10 @@ mesh.z = -mesh_size : mesh_size : coil_length+mesh_size;
|
|||
mesh.z = [mesh.z(1)-add_Lines mesh.z mesh.z(end)+add_Lines ];
|
||||
CSX = DefineRectGrid(CSX, 1e-3,mesh);
|
||||
|
||||
%create copper helix and feed lines...
|
||||
%% build/define helix %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
CSX = AddMaterial(CSX,'copper');
|
||||
CSX = SetMaterialProperty(CSX,'copper','Kappa',56e6);
|
||||
|
||||
%build helix-wire
|
||||
dt = 1.0/coil_res;
|
||||
height=0;
|
||||
wire.Vertex = {};
|
||||
|
@ -78,6 +80,7 @@ p(2,count+2) = 0;
|
|||
p(3,count+2) = 0.5*(coil_length+port_length);
|
||||
CSX = AddWire(CSX, 'copper', 0, p, wire_rad);
|
||||
|
||||
%% apply the excitation & resist as a current source%%%%%%%%%%%%%%%%%%%%%%%
|
||||
CSX = AddMaterial(CSX,'resist');
|
||||
kappa = port_length/port_resist/wire_rad^2/pi/1e-3;
|
||||
CSX = SetMaterialProperty(CSX,'resist','Kappa',kappa);
|
||||
|
@ -87,10 +90,10 @@ stop=[coil_rad+feed_length 0 (coil_length+port_length)/2];
|
|||
%start(3)=(coil_length-port_length)/2;stop(3)=(coil_length+port_length)/2;
|
||||
CSX = AddCylinder(CSX,'resist',5 ,start,stop,wire_rad);
|
||||
|
||||
%excitation
|
||||
CSX = AddExcitation(CSX,'excite',0,[0 0 1]);
|
||||
CSX = AddCylinder(CSX,'excite', 0 ,start,stop,wire_rad);
|
||||
|
||||
%% define voltage calc boxes %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%voltage calc
|
||||
CSX = AddProbe(CSX,'ut1',0);
|
||||
CSX = AddBox(CSX,'ut1', 0 ,stop,start);
|
||||
|
@ -102,7 +105,7 @@ start(1) = start(1)-2;start(2) = start(2)-2;
|
|||
stop(1) = stop(1)+2;stop(2) = stop(2)+2;
|
||||
CSX = AddBox(CSX,'it1', 0 ,start,stop);
|
||||
|
||||
%dump
|
||||
%% define dump boxes... %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
CSX = AddDump(CSX,'Et_');
|
||||
start = [mesh.x(1) , 0 , mesh.z(1)];
|
||||
stop = [mesh.x(end) , 0 , mesh.z(end)];
|
||||
|
@ -113,10 +116,10 @@ start = [mesh.x(1) , 0 , mesh.z(1)];
|
|||
stop = [mesh.x(end) , 0 , mesh.z(end)];
|
||||
CSX = AddBox(CSX,'Ht_',0 , start,stop);
|
||||
|
||||
%Write openEMS compatoble xml-file
|
||||
%% Write openEMS compatoble xml-file %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
WriteOpenEMS([Sim_Path '/' Sim_CSX],FDTD,CSX);
|
||||
|
||||
%cd to working dir and run openEMS
|
||||
%% cd to working dir and run openEMS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
savePath = pwd();
|
||||
cd(Sim_Path); %cd to working dir
|
||||
command = [openEMS_Path 'openEMS.sh ' Sim_CSX ' ' openEMS_opts];
|
||||
|
@ -124,7 +127,7 @@ disp(command);
|
|||
system(command)
|
||||
cd(savePath);
|
||||
|
||||
%%%post-proc
|
||||
%% postproc & do the plots %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
U = ReadUI('ut1','tmp/');
|
||||
I = ReadUI('it1','tmp/');
|
||||
|
||||
|
@ -147,5 +150,12 @@ plot(f(ind)*1e-6,R(ind),'Linewidth',2);
|
|||
hold on
|
||||
plot(f(ind)*1e-6,imag(Z(ind)),'r','Linewidth',2);
|
||||
xlabel('frequency (MHz)');
|
||||
ylabel('resistance (\Omega)');
|
||||
ylabel('resistance (Ohm)');
|
||||
grid on;
|
||||
legend( {'real','imaginary'}, 'location', 'northwest' )
|
||||
|
||||
figure
|
||||
plot(U.TD{1}.t/1e-6,U.TD{1}.val,'Linewidth',2);
|
||||
xlabel('time (us)');
|
||||
ylabel('amplitude (V)');
|
||||
grid on;
|
||||
|
|
|
@ -2,6 +2,7 @@ close all;
|
|||
clear all;
|
||||
clc
|
||||
|
||||
%% setup the simulation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
abs_length = 250;
|
||||
length = 1000;
|
||||
width = 500;
|
||||
|
@ -13,23 +14,24 @@ mesh_res = [5 5 10];
|
|||
EPS0 = 8.85418781762e-12;
|
||||
MUE0 = 1.256637062e-6;
|
||||
|
||||
%% define file pathes and openEMS options %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
openEMS_Path = [pwd() '/../../']
|
||||
openEMS_opts = '';
|
||||
% openEMS_opts = [openEMS_opts ' --disable-dumps'];
|
||||
openEMS_opts = [openEMS_opts ' --debug-material'];
|
||||
% openEMS_opts = [openEMS_opts ' --debug-material'];
|
||||
|
||||
Sim_Path = 'tmp';
|
||||
Sim_CSX = 'msl.xml';
|
||||
|
||||
mkdir(Sim_Path);
|
||||
|
||||
%setup FDTD parameter
|
||||
%% setup FDTD parameter & excitation function %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
FDTD = InitFDTD(5e5,1e-6);
|
||||
FDTD = SetGaussExcite(FDTD,0.5e9,0.5e9);
|
||||
BC = [1 1 0 1 0 0];
|
||||
FDTD = SetBoundaryCond(FDTD,BC);
|
||||
|
||||
%setup CSXCAD geometry
|
||||
%% setup CSXCAD geometry & mesh %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
CSX = InitCSX();
|
||||
mesh.x = -width/2 : mesh_res(1) : width/2;
|
||||
mesh.y = [linspace(0,MSL_height,11) MSL_height+1 MSL_height+3 MSL_height+mesh_res(2):mesh_res(2):height];
|
||||
|
@ -46,7 +48,7 @@ start = [-0.5*MSL_width, 0 , 0];stop = [0.5*MSL_width, MSL_height , mesh_res(1)/
|
|||
CSX = AddExcitation(CSX,'excite',0,[0 -1 0]);
|
||||
CSX = AddBox(CSX,'excite',0 ,start,stop);
|
||||
|
||||
%%%fake pml
|
||||
%% fake pml %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
finalKappa = 0.3/abs_length^4;
|
||||
finalSigma = finalKappa*MUE0/EPS0;
|
||||
CSX = AddMaterial(CSX,'pml');
|
||||
|
@ -58,7 +60,7 @@ start = [mesh.x(1) mesh.y(1) length-abs_length];
|
|||
stop = [mesh.x(end) mesh.y(end) length];
|
||||
CSX = AddBox(CSX,'pml',0 ,start,stop);
|
||||
|
||||
%dump
|
||||
%% define dump boxes... %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
CSX = AddDump(CSX,'Et_','DumpMode',2);
|
||||
start = [mesh.x(1) , MSL_height/2 , mesh.z(1)];
|
||||
stop = [mesh.x(end) , MSL_height/2 , mesh.z(end)];
|
||||
|
@ -67,6 +69,7 @@ CSX = AddBox(CSX,'Et_',0 , start,stop);
|
|||
CSX = AddDump(CSX,'Ht_','DumpType',1,'DumpMode',2);
|
||||
CSX = AddBox(CSX,'Ht_',0,start,stop);
|
||||
|
||||
%% define voltage calc boxes %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%voltage calc
|
||||
CSX = AddProbe(CSX,'ut1',0);
|
||||
start = [ 0 MSL_height length/2 ];stop = [ 0 0 length/2 ];
|
||||
|
@ -77,10 +80,10 @@ CSX = AddProbe(CSX,'it1',1);
|
|||
start = [ -MSL_width MSL_height/2 length/2 ];stop = [ MSL_width MSL_height*1.5 length/2 ];
|
||||
CSX = AddBox(CSX,'it1', 0 ,start,stop);
|
||||
|
||||
%Write openEMS compatoble xml-file
|
||||
%% Write openEMS compatoble xml-file %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
WriteOpenEMS([Sim_Path '/' Sim_CSX],FDTD,CSX);
|
||||
|
||||
%cd to working dir and run openEMS
|
||||
%% cd to working dir and run openEMS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
savePath = pwd();
|
||||
cd(Sim_Path); %cd to working dir
|
||||
command = [openEMS_Path 'openEMS.sh ' Sim_CSX ' ' openEMS_opts];
|
||||
|
|
|
@ -2,6 +2,7 @@ close all;
|
|||
clear all;
|
||||
clc
|
||||
|
||||
%% setup the simulation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
abs_length = 250;
|
||||
length = 4000;
|
||||
width = 1000;
|
||||
|
@ -11,24 +12,25 @@ mesh_res = 25;
|
|||
EPS0 = 8.85418781762e-12;
|
||||
MUE0 = 1.256637062e-6;
|
||||
|
||||
%% define file pathes and openEMS options %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
openEMS_Path = [pwd() '/../../']
|
||||
openEMS_opts = '';
|
||||
% openEMS_opts = [openEMS_opts ' --disable-dumps'];
|
||||
% openEMS_opts = [openEMS_opts ' --debug-material'];
|
||||
openEMS_opts = [openEMS_opts ' --engine=multithreaded'];
|
||||
% openEMS_opts = [openEMS_opts ' --engine=multithreaded'];
|
||||
|
||||
Sim_Path = 'tmp';
|
||||
Sim_CSX = 'plane_wave.xml';
|
||||
|
||||
mkdir(Sim_Path);
|
||||
|
||||
%setup FDTD parameter
|
||||
FDTD = InitFDTD(5e5,1e-6);
|
||||
%% setup FDTD parameter & excitation function %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
FDTD = InitFDTD(5e5,1e-6,'OverSampling',10);
|
||||
FDTD = SetGaussExcite(FDTD,0.5e9,0.5e9);
|
||||
BC = [1 1 0 0 0 0];
|
||||
FDTD = SetBoundaryCond(FDTD,BC);
|
||||
|
||||
%setup CSXCAD geometry
|
||||
%% setup CSXCAD geometry & mesh %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
CSX = InitCSX();
|
||||
mesh.x = -width/2 : mesh_res : width/2;
|
||||
mesh.y = -height/2 : mesh_res : height/2;
|
||||
|
@ -36,7 +38,7 @@ mesh.z = 0 : mesh_res : length;
|
|||
CSX = DefineRectGrid(CSX, 1e-3,mesh);
|
||||
|
||||
|
||||
%%%fake pml
|
||||
%% fake pml %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
finalKappa = 0.3/abs_length^4;
|
||||
finalSigma = finalKappa*MUE0/EPS0;
|
||||
CSX = AddMaterial(CSX,'pml');
|
||||
|
@ -48,24 +50,25 @@ start=[-width/2 -height/2 length-abs_length];
|
|||
stop=[width/2 height/2 length];
|
||||
CSX = AddBox(CSX,'pml',0 ,start,stop);
|
||||
|
||||
%% apply the excitation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
start=[-width/2 -height/2 0];
|
||||
stop=[width/2 height/2 0];
|
||||
CSX = AddExcitation(CSX,'excite',0,[0 1 0]);
|
||||
CSX = AddBox(CSX,'excite',0 ,start,stop);
|
||||
|
||||
%dump
|
||||
CSX = AddDump(CSX,'Et','FileType',1);
|
||||
start = [mesh.x(1) , 0 , mesh.z(1)];
|
||||
stop = [mesh.x(end) , 0 , mesh.z(end)];
|
||||
%% define dump boxes... %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
CSX = AddDump(CSX,'Et','FileType',1,'SubSampling','4,4,1');
|
||||
start = [mesh.x(1) , mesh.y(1) , mesh.z(1)];
|
||||
stop = [mesh.x(end) , mesh.y(end) , mesh.z(end)];
|
||||
CSX = AddBox(CSX,'Et',0 , start,stop);
|
||||
|
||||
CSX = AddDump(CSX,'Ht','DumpType',1,'FileType',1);
|
||||
CSX = AddDump(CSX,'Ht','DumpType',1,'FileType',1,'SubSampling','4,4,1');
|
||||
CSX = AddBox(CSX,'Ht',0,start,stop);
|
||||
|
||||
%Write openEMS compatoble xml-file
|
||||
%% Write openEMS compatoble xml-file %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
WriteOpenEMS([Sim_Path '/' Sim_CSX],FDTD,CSX);
|
||||
|
||||
%cd to working dir and run openEMS
|
||||
%% cd to working dir and run openEMS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
savePath = pwd();
|
||||
cd(Sim_Path); %cd to working dir
|
||||
command = [openEMS_Path 'openEMS.sh ' Sim_CSX ' ' openEMS_opts];
|
||||
|
@ -73,11 +76,11 @@ disp(command);
|
|||
system(command)
|
||||
cd(savePath);
|
||||
|
||||
% plotting
|
||||
PlotArgs.plane='zx';
|
||||
%% do the plots %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
PlotArgs.slice = {mesh.x(round(end/2)) mesh.y(round(end/2)) mesh.z(round(end/2))};
|
||||
PlotArgs.pauseTime=0.01;
|
||||
PlotArgs.component=2;
|
||||
PlotArgs.zlim='auto';
|
||||
PlotArgs.Limit = 'auto';
|
||||
|
||||
PlotHDF5FieldData('tmp/Et.h5',PlotArgs)
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ close all;
|
|||
clear all;
|
||||
clc
|
||||
|
||||
%% setup the simulation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
abs_length = 250;
|
||||
length = 4000;
|
||||
unit = 1e-3;
|
||||
|
@ -29,6 +30,7 @@ beta = sqrt(k^2 - kc^2);
|
|||
func_Ex = [num2str(n/b/unit) '*cos(' num2str(m*pi/a) '*x)*sin(' num2str(n*pi/b) '*y)'];
|
||||
func_Ey = [num2str(m/a/unit) '*sin(' num2str(m*pi/a) '*x)*cos(' num2str(n*pi/b) '*y)'];
|
||||
|
||||
%% define file pathes and openEMS options %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
openEMS_Path = [pwd() '/../../']
|
||||
openEMS_opts = '';
|
||||
% openEMS_opts = [openEMS_opts ' --disable-dumps'];
|
||||
|
@ -40,21 +42,20 @@ Sim_CSX = 'rect_wg.xml';
|
|||
|
||||
mkdir(Sim_Path);
|
||||
|
||||
%setup FDTD parameter
|
||||
%% setup FDTD parameter & excitation function %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
FDTD = InitFDTD(500,1e-6,'OverSampling',6);
|
||||
FDTD = SetSinusExcite(FDTD,f0);
|
||||
BC = [0 0 0 0 0 0];
|
||||
FDTD = SetBoundaryCond(FDTD,BC);
|
||||
|
||||
%setup CSXCAD geometry
|
||||
%% setup CSXCAD geometry & mesh %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
CSX = InitCSX();
|
||||
mesh.x = 0 : mesh_res(1) : width;
|
||||
mesh.y = 0 : mesh_res(2) : height;
|
||||
mesh.z = -length: mesh_res(3) : length;
|
||||
CSX = DefineRectGrid(CSX, unit,mesh);
|
||||
|
||||
|
||||
%%%fake pml
|
||||
%% fake pml %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
finalKappa = 0.3/abs_length^4;
|
||||
finalSigma = finalKappa*MUE0/EPS0;
|
||||
CSX = AddMaterial(CSX,'pml');
|
||||
|
@ -69,6 +70,7 @@ start=[0 0 -length+abs_length];
|
|||
stop=[width height -length];
|
||||
CSX = AddBox(CSX,'pml',0 ,start,stop);
|
||||
|
||||
%% apply the excitation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
start=[0 0 0];
|
||||
stop=[width height 0];
|
||||
CSX = AddExcitation(CSX,'excite',0,[1 1 0]);
|
||||
|
@ -78,7 +80,7 @@ weight{3} = 0;
|
|||
CSX = SetExcitationWeight(CSX,'excite',weight);
|
||||
CSX = AddBox(CSX,'excite',0 ,start,stop);
|
||||
|
||||
%dump
|
||||
%% define dump boxes... %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
CSX = AddDump(CSX,'Et','FileType',1);
|
||||
start = [mesh.x(1) , height/2 , mesh.z(1)];
|
||||
stop = [mesh.x(end) , height/2 , mesh.z(end)];
|
||||
|
@ -87,10 +89,10 @@ CSX = AddBox(CSX,'Et',0 , start,stop);
|
|||
CSX = AddDump(CSX,'Ht','DumpType',1,'FileType',1);
|
||||
CSX = AddBox(CSX,'Ht',0,start,stop);
|
||||
|
||||
%Write openEMS compatoble xml-file
|
||||
%% Write openEMS compatoble xml-file %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
WriteOpenEMS([Sim_Path '/' Sim_CSX],FDTD,CSX);
|
||||
|
||||
%cd to working dir and run openEMS
|
||||
%% cd to working dir and run openEMS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
savePath = pwd();
|
||||
cd(Sim_Path); %cd to working dir
|
||||
command = [openEMS_Path 'openEMS.sh ' Sim_CSX ' ' openEMS_opts];
|
||||
|
@ -98,11 +100,11 @@ disp(command);
|
|||
system(command)
|
||||
cd(savePath);
|
||||
|
||||
% plotting
|
||||
PlotArgs.plane='zx';
|
||||
PlotArgs.pauseTime=0.1;
|
||||
%% do the plots %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
PlotArgs.slice = {mesh.x(round(end/2)) mesh.y(round(end/2)) mesh.z(round(end/2))};
|
||||
PlotArgs.pauseTime=0.01;
|
||||
PlotArgs.component=2;
|
||||
PlotArgs.zlim='auto';
|
||||
PlotArgs.Limit = 'auto';
|
||||
|
||||
PlotHDF5FieldData('tmp/Et.h5',PlotArgs)
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
106
openEMS.pro
106
openEMS.pro
|
@ -1,25 +1,32 @@
|
|||
# -------------------------------------------------
|
||||
# Project created by QtCreator 2010-02-26T22:34:51
|
||||
# -------------------------------------------------
|
||||
QT -= gui \
|
||||
core
|
||||
TARGET = openEMS
|
||||
CONFIG += console
|
||||
CONFIG -= app_bundle qt
|
||||
TEMPLATE = app
|
||||
OBJECTS_DIR = obj
|
||||
INCLUDEPATH += .
|
||||
INCLUDEPATH += ../CSXCAD \
|
||||
../fparser \
|
||||
../tinyxml
|
||||
LIBS += -L../CSXCAD \
|
||||
-lCSXCAD \
|
||||
-L../fparser \
|
||||
-lfparser \
|
||||
-L../tinyxml \
|
||||
-ltinyxml \
|
||||
-lboost_thread \
|
||||
-lhdf5 \
|
||||
-lhdf5_cpp
|
||||
LIBS += -L../CSXCAD -lCSXCAD
|
||||
|
||||
win32 {
|
||||
INCLUDEPATH += ../hdf5/include ../boost/include/boost-1_42
|
||||
LIBS += ../hdf5/lib/libhdf5_cpp.a ../hdf5/lib/libhdf5.a
|
||||
LIBS += ../boost/lib/libboost_thread-mgw44-mt.lib
|
||||
LIBS += -L../CSXCAD/release
|
||||
LIBS += ../fparser/release/libfparser4.a
|
||||
LIBS += ../tinyxml/release/libtinyxml2.a
|
||||
}
|
||||
!win32 {
|
||||
LIBS += ../fparser/libfparser.so
|
||||
LIBS += ../tinyxml/libtinyxml.so
|
||||
LIBS += -lboost_thread
|
||||
LIBS += -lhdf5 -lhdf5_cpp
|
||||
}
|
||||
|
||||
QMAKE_LFLAGS += \'-Wl,-rpath,\$$ORIGIN/../CSXCAD\'
|
||||
QMAKE_LFLAGS += \'-Wl,-rpath,\$$ORIGIN/../fparser\'
|
||||
QMAKE_LFLAGS += \'-Wl,-rpath,\$$ORIGIN/../tinyxml\'
|
||||
|
@ -38,9 +45,13 @@ SOURCES += main.cpp \
|
|||
openems.cpp \
|
||||
FDTD/engine_multithread.cpp \
|
||||
FDTD/operator_cylinder.cpp \
|
||||
FDTD/engine_cylinder.cpp \
|
||||
FDTD/engine_cylinder.cpp \
|
||||
FDTD/engine_sse.cpp \
|
||||
FDTD/operator_sse.cpp
|
||||
FDTD/operator_sse.cpp \
|
||||
FDTD/operator_extension.cpp \
|
||||
FDTD/engine_extension.cpp \
|
||||
FDTD/engine_ext_mur_abc.cpp \
|
||||
FDTD/operator_ext_mur_abc.cpp
|
||||
HEADERS += tools/ErrorMsg.h \
|
||||
tools/AdrOp.h \
|
||||
tools/constants.h \
|
||||
|
@ -55,13 +66,72 @@ HEADERS += tools/ErrorMsg.h \
|
|||
examples/FDTD_examples.h \
|
||||
openems.h \
|
||||
FDTD/engine_multithread.h \
|
||||
FDTD/operator_cylinder.h \
|
||||
FDTD/engine_cylinder.h \
|
||||
FDTD/operator_cylinder.h \
|
||||
FDTD/engine_sse.h \
|
||||
FDTD/operator_sse.h
|
||||
QMAKE_CXXFLAGS_RELEASE = -O3 \
|
||||
FDTD/operator_sse.h \
|
||||
FDTD/engine_cylinder.h \
|
||||
FDTD/operator_extension.h \
|
||||
FDTD/engine_extension.h \
|
||||
FDTD/engine_ext_mur_abc.h \
|
||||
FDTD/operator_ext_mur_abc.h
|
||||
QMAKE_CXXFLAGS_RELEASE = -O2 \
|
||||
-g \
|
||||
-march=native
|
||||
-march=native
|
||||
QMAKE_CXXFLAGS_DEBUG = -O0 \
|
||||
-g \
|
||||
-march=native
|
||||
|
||||
|
||||
#
|
||||
# to use ABI2 target:
|
||||
# qmake CONFIG+="ABI2 bits64" -o Makefile.ABI2-64 openEMS.pro
|
||||
# make -fMakefile.ABI2-64
|
||||
#
|
||||
|
||||
ABI2 {
|
||||
CONFIG-=debug debug_and_release
|
||||
CONFIG+=release
|
||||
QMAKE_CFLAGS_RELEASE=-O2 -fabi-version=2
|
||||
QMAKE_CXXFLAGS_RELEASE=-O2 -fabi-version=2
|
||||
QMAKE_CC = apgcc
|
||||
QMAKE_CXX = apg++
|
||||
QMAKE_LINK = apg++
|
||||
QMAKE_LINK_SHLIB = apg++
|
||||
QMAKE_LFLAGS_RPATH =
|
||||
QMAKE_LFLAGS = \'-Wl,-rpath,\$$ORIGIN/lib\'
|
||||
}
|
||||
|
||||
bits64 {
|
||||
QMAKE_CXXFLAGS_RELEASE+=-m64 -march=athlon64
|
||||
QMAKE_LFLAGS_RELEASE+=-m64 -march=athlon64
|
||||
OBJECTS_DIR = ABI2-64
|
||||
LIBS = ../CSXCAD/ABI2-64/libCSXCAD.so
|
||||
LIBS += ../fparser/ABI2-64/libfparser.so
|
||||
LIBS += ../tinyxml/ABI2-64/libtinyxml.so
|
||||
LIBS += ../boost-64/lib/libboost_thread.so
|
||||
LIBS += ../hdf5-64/lib/libhdf5.so
|
||||
LIBS += ../hdf5-64/lib/libhdf5_cpp.so -lpthread
|
||||
INCLUDEPATH += ../hdf5-64/include
|
||||
INCLUDEPATH += ../boost-64/include
|
||||
}
|
||||
|
||||
bits32 {
|
||||
QMAKE_CXXFLAGS_RELEASE+=-m32 -march=i686
|
||||
QMAKE_LFLAGS_RELEASE+=-m32 -march=i686
|
||||
OBJECTS_DIR = ABI2-32
|
||||
LIBS = ../CSXCAD/ABI2-32/libCSXCAD.so
|
||||
LIBS += ../fparser/ABI2-32/libfparser.so
|
||||
LIBS += ../tinyxml/ABI2-32/libtinyxml.so
|
||||
LIBS += ../boost-32/lib/libboost_thread.so
|
||||
LIBS += ../hdf5-32/lib/libhdf5.so
|
||||
LIBS += ../hdf5-32/lib/libhdf5_cpp.so
|
||||
INCLUDEPATH += ../hdf5-32/include
|
||||
INCLUDEPATH += ../boost-32/include
|
||||
}
|
||||
|
||||
ABI2 {
|
||||
DESTDIR = $$OBJECTS_DIR
|
||||
MOC_DIR = $$OBJECTS_DIR
|
||||
UI_DIR = $$OBJECTS_DIR
|
||||
RCC_DIR = $$OBJECTS_DIR
|
||||
}
|
||||
|
|
13
openems.cpp
13
openems.cpp
|
@ -22,6 +22,7 @@
|
|||
#include "FDTD/engine_cylinder.h"
|
||||
#include "FDTD/engine_multithread.h"
|
||||
#include "FDTD/engine_sse.h"
|
||||
#include "FDTD/operator_ext_mur_abc.h"
|
||||
#include "FDTD/processvoltage.h"
|
||||
#include "FDTD/processcurrent.h"
|
||||
#include "FDTD/processfields_td.h"
|
||||
|
@ -265,6 +266,18 @@ int openEMS::SetupFDTD(const char* file)
|
|||
|
||||
if (FDTD_Op->SetGeometryCSX(&CSX)==false) return(2);
|
||||
|
||||
/**************************** create all operator/engine extensions here !!!! **********************************/
|
||||
//Mur-ABC
|
||||
for (int n=0;n<6;++n)
|
||||
{
|
||||
if (bounds[n]==2)
|
||||
{
|
||||
Operator_Ext_Mur_ABC* op_ext_mur = new Operator_Ext_Mur_ABC(FDTD_Op);
|
||||
op_ext_mur->SetDirection(n/2,n%2);
|
||||
FDTD_Op->AddExtension(op_ext_mur);
|
||||
}
|
||||
}
|
||||
|
||||
FDTD_Op->CalcECOperator();
|
||||
|
||||
SetupExcitation(FDTD_Opts->FirstChildElement("Excitation"));
|
||||
|
|
|
@ -18,6 +18,33 @@
|
|||
#include "array_ops.h"
|
||||
#include <ostream>
|
||||
|
||||
FDTD_FLOAT** Create2DArray(const unsigned int* numLines)
|
||||
{
|
||||
FDTD_FLOAT** array=NULL;
|
||||
unsigned int pos[3];
|
||||
array = new FDTD_FLOAT*[numLines[0]];
|
||||
for (pos[0]=0;pos[0]<numLines[0];++pos[0])
|
||||
{
|
||||
array[pos[0]] = new FDTD_FLOAT[numLines[1]];
|
||||
for (pos[1]=0;pos[1]<numLines[1];++pos[1])
|
||||
{
|
||||
array[pos[0]][pos[1]] = 0;
|
||||
}
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
void Delete2DArray(FDTD_FLOAT** array, const unsigned int* numLines)
|
||||
{
|
||||
if (array==NULL) return;
|
||||
unsigned int pos[3];
|
||||
for (pos[0]=0;pos[0]<numLines[0];++pos[0])
|
||||
{
|
||||
delete[] array[pos[0]];
|
||||
}
|
||||
delete[] array;
|
||||
}
|
||||
|
||||
FDTD_FLOAT*** Create3DArray(const unsigned int* numLines)
|
||||
{
|
||||
FDTD_FLOAT*** array=NULL;
|
||||
|
|
|
@ -33,6 +33,9 @@ union f4vector
|
|||
|
||||
#include "FDTD/operator.h"
|
||||
|
||||
FDTD_FLOAT** Create2DArray(const unsigned int* numLines);
|
||||
void Delete2DArray(FDTD_FLOAT** array, const unsigned int* numLines);
|
||||
|
||||
FDTD_FLOAT*** Create3DArray(const unsigned int* numLines);
|
||||
void Delete3DArray(FDTD_FLOAT*** array, const unsigned int* numLines);
|
||||
|
||||
|
|
Loading…
Reference in New Issue