From 3b44620278f2c5c230052ee8a4e77dc84607f4e9 Mon Sep 17 00:00:00 2001 From: Thorsten Liebig Date: Tue, 22 Jan 2013 09:22:01 +0100 Subject: [PATCH] current probes can be a point or line which allows for 1D/2D lumped ports - this needs the new probe box interface in CSXCAD - most tutorials have been updated Signed-off-by: Thorsten Liebig --- Common/processcurrent.cpp | 44 ++++++++++++++++++++----- Common/processcurrent.h | 1 - Common/processintegral.cpp | 1 + Common/processintegral.h | 4 +++ matlab/AddLumpedPort.m | 8 ++--- matlab/AddMSLPort.m | 10 +++--- matlab/Tutorials/CRLH_Extraction.m | 2 +- matlab/Tutorials/CRLH_LeakyWaveAnt.m | 10 +++--- matlab/Tutorials/Circ_Waveguide.m | 8 ++--- matlab/Tutorials/Rect_Waveguide.m | 8 ++--- matlab/Tutorials/Simple_Patch_Antenna.m | 5 ++- openems.cpp | 3 +- 12 files changed, 68 insertions(+), 36 deletions(-) diff --git a/Common/processcurrent.cpp b/Common/processcurrent.cpp index 8db91fd..8c35bf0 100644 --- a/Common/processcurrent.cpp +++ b/Common/processcurrent.cpp @@ -40,23 +40,51 @@ void ProcessCurrent::DefineStartStopCoord(double* dstart, double* dstop) { ProcessIntegral::DefineStartStopCoord(dstart, dstop); - m_normDir = -1; - for (int n=0; n<3; ++n) + if ((m_normDir<0) || (m_normDir>2)) { - if (stop[n] == start[n]) - m_normDir = n; + if (m_Dimension!=2) + { + cerr << "ProcessCurrent::DefineStartStopCoord(): Warning Current Integration Box \"" << m_filename << "\" is not a surface (found dimension: " << m_Dimension << ") nor has it set a valid normal direction! --> disabled" << endl; + SetEnable(false); + return; + } + + for (int n=0; n<3; ++n) + { + if (stop[n] == start[n]) + m_normDir = n; + } + } + else + { + //expand dimension to 2 if possible + m_Dimension = 0; + for (int n=0; n<3; ++n) + { + if (n==m_normDir) + continue; + if (dstart[n]==dstop[n]) + { + if ((Op->GetDiscLine( n, start[n], true ) > dstart[n]) && (start[n]>0)) + --start[n]; + if ((Op->GetDiscLine( n, start[n], true ) < dstart[n]) && (stop[n]GetNumberOfLines(n)-1)) + ++stop[n]; + } + if (stop[n] > start[n]) + ++m_Dimension; + } } - if (m_normDir<0) + if (start[m_normDir]!=stop[m_normDir]) { - cerr << "ProcessCurrent::DefineStartStopCoord(): Warning Current Integration Box \"" << m_filename << "\" has an invalid normal direction --> disabled" << endl; + cerr << "ProcessCurrent::DefineStartStopCoord(): Warning Current Integration Box \"" << m_filename << "\" has an expansion in normal direction! --> disabled" << endl; SetEnable(false); return; } - if (m_Dimension!=2) + if ((m_normDir<0) || (m_normDir>2)) { - cerr << "ProcessCurrent::DefineStartStopCoord(): Warning Current Integration Box \"" << m_filename << "\" is not a surface (found dimension: " << m_Dimension << ") --> disabled" << endl; + cerr << "ProcessCurrent::DefineStartStopCoord(): Warning Current Integration Box \"" << m_filename << "\" has an invalid normal direction --> disabled" << endl; SetEnable(false); return; } diff --git a/Common/processcurrent.h b/Common/processcurrent.h index 79ca947..0606531 100644 --- a/Common/processcurrent.h +++ b/Common/processcurrent.h @@ -36,7 +36,6 @@ public: virtual double CalcIntegral(); protected: - int m_normDir; //current box has to be 2D plane, this is the normal direction }; #endif // PROCESSCURRENT_H diff --git a/Common/processintegral.cpp b/Common/processintegral.cpp index 4d0c602..6010e0f 100644 --- a/Common/processintegral.cpp +++ b/Common/processintegral.cpp @@ -24,6 +24,7 @@ ProcessIntegral::ProcessIntegral(Engine_Interface_Base* eng_if) : Processing(en { m_Results=NULL; m_FD_Results=NULL; + m_normDir = -1; } ProcessIntegral::~ProcessIntegral() diff --git a/Common/processintegral.h b/Common/processintegral.h index ea57ca6..d7d611d 100644 --- a/Common/processintegral.h +++ b/Common/processintegral.h @@ -33,6 +33,8 @@ public: virtual string GetProcessingName() const = 0; + virtual void GetNormalDir(int nd) {m_normDir=nd;} + //! Flush FD data to disk virtual void FlushData(); @@ -62,6 +64,8 @@ protected: vector *m_FD_Results; double *m_Results; + + int m_normDir; // normal direction as required by some integral processings }; #endif // PROCESSINTEGRAL_H diff --git a/matlab/AddLumpedPort.m b/matlab/AddLumpedPort.m index faf8bd7..8f09b50 100644 --- a/matlab/AddLumpedPort.m +++ b/matlab/AddLumpedPort.m @@ -47,8 +47,8 @@ else error 'dir must have exactly one component ~= 0' end -if (sum(start==stop)>0) - error 'start/stop in must not be equal in any direction --> lumped port needs a 3D box' +if (stop(n_dir)==start(n_dir)) + error 'start/stop in excitation direction in must not be equal' end if (stop(n_dir)-start(n_dir)) > 0 @@ -93,7 +93,7 @@ u_stop = 0.5*(start + stop); u_start(n_dir) = start(n_dir); u_stop(n_dir) = stop(n_dir); -CSX = AddProbe(CSX,['port_ut' int2str(portnr)], 0, -direction); +CSX = AddProbe(CSX,['port_ut' int2str(portnr)], 0, 'weight', -direction); CSX = AddBox(CSX,['port_ut' int2str(portnr)], prio, u_start, u_stop); i_start = start; @@ -101,6 +101,6 @@ i_stop = stop; i_start(n_dir) = 0.5*(start(n_dir)+stop(n_dir)); i_stop(n_dir) = 0.5*(start(n_dir)+stop(n_dir)); -CSX = AddProbe(CSX,['port_it' int2str(portnr)], 1, direction); +CSX = AddProbe(CSX,['port_it' int2str(portnr)], 1, 'weight', direction, 'NormDir', n_dir-1); CSX = AddBox(CSX,['port_it' int2str(portnr)], prio, i_start, i_stop); diff --git a/matlab/AddMSLPort.m b/matlab/AddMSLPort.m index 757b267..f412c02 100644 --- a/matlab/AddMSLPort.m +++ b/matlab/AddMSLPort.m @@ -192,21 +192,21 @@ i2_stop(idx_prop) = i2_start(idx_prop); name = ['port_ut' num2str(portnr) 'A']; % weight = sign(stop(idx_height)-start(idx_height)) weight = upsidedown; -CSX = AddProbe( CSX, name, 0, weight ); +CSX = AddProbe( CSX, name, 0, 'weight', weight ); CSX = AddBox( CSX, name, prio, v1_start, v1_stop ); name = ['port_ut' num2str(portnr) 'B']; -CSX = AddProbe( CSX, name, 0, weight ); +CSX = AddProbe( CSX, name, 0, 'weight', weight ); CSX = AddBox( CSX, name, prio, v2_start, v2_stop ); name = ['port_ut' num2str(portnr) 'C']; -CSX = AddProbe( CSX, name, 0, weight ); +CSX = AddProbe( CSX, name, 0, 'weight', weight ); CSX = AddBox( CSX, name, prio, v3_start, v3_stop ); name = ['port_it' num2str(portnr) 'A']; weight = direction; -CSX = AddProbe( CSX, name, 1, weight ); +CSX = AddProbe( CSX, name, 1, 'weight', weight ); CSX = AddBox( CSX, name, prio, i1_start, i1_stop ); name = ['port_it' num2str(portnr) 'B']; -CSX = AddProbe( CSX, name, 1, weight ); +CSX = AddProbe( CSX, name, 1,'weight', weight ); CSX = AddBox( CSX, name, prio, i2_start, i2_stop ); % create port structure diff --git a/matlab/Tutorials/CRLH_Extraction.m b/matlab/Tutorials/CRLH_Extraction.m index faed9c7..cf1e616 100644 --- a/matlab/Tutorials/CRLH_Extraction.m +++ b/matlab/Tutorials/CRLH_Extraction.m @@ -73,7 +73,7 @@ end CSX = AddMetal( CSX, 'PEC' ); portstart = [ mesh.x(1) , -CRLH.LW/2, substratelines(end)]; portstop = [ -CRLH.LL/2, CRLH.LW/2, 0]; -[CSX,port{1}] = AddMSLPort( CSX, 999, 1, 'PEC', portstart, portstop, 0, [0 0 -1], 'ExcitePort', 'excite', 'FeedShift', 10*resolution(1), 'MeasPlaneShift', feed_length/2); +[CSX,port{1}] = AddMSLPort( CSX, 999, 1, 'PEC', portstart, portstop, 0, [0 0 -1], 'ExcitePort', true, 'FeedShift', 10*resolution(1), 'MeasPlaneShift', feed_length/2); portstart = [ mesh.x(end) , -CRLH.LW/2, substratelines(end)]; portstop = [ +CRLH.LL/2, CRLH.LW/2, 0]; diff --git a/matlab/Tutorials/CRLH_LeakyWaveAnt.m b/matlab/Tutorials/CRLH_LeakyWaveAnt.m index 180eb2f..c427187 100644 --- a/matlab/Tutorials/CRLH_LeakyWaveAnt.m +++ b/matlab/Tutorials/CRLH_LeakyWaveAnt.m @@ -108,12 +108,12 @@ stop = [mesh.x(end) mesh.y(end) mesh.z(end)] - 10*resolution; Sim_Path = 'tmp_CRLH_LeakyWave'; Sim_CSX = 'CRLH.xml'; -[status, message, messageid] = rmdir( Sim_Path, 's' ); % clear previous directory -[status, message, messageid] = mkdir( Sim_Path ); % create empty simulation folder +% [status, message, messageid] = rmdir( Sim_Path, 's' ); % clear previous directory +% [status, message, messageid] = mkdir( Sim_Path ); % create empty simulation folder -WriteOpenEMS( [Sim_Path '/' Sim_CSX], FDTD, CSX ); +% WriteOpenEMS( [Sim_Path '/' Sim_CSX], FDTD, CSX ); CSXGeomPlot( [Sim_Path '/' Sim_CSX] ); -RunOpenEMS( Sim_Path, Sim_CSX ); +% RunOpenEMS( Sim_Path, Sim_CSX ); %% post-processing close all @@ -140,7 +140,7 @@ phi = 0:2:360; theta = 0:2:180; disp( 'calculating 3D far field pattern...' ); -nf2ff = CalcNF2FF(nf2ff, Sim_Path, f_rad, theta*pi/180, phi*pi/180, 'Outfile','3D_Pattern.h5', 'Mode', 1,'Verbose',1); +nf2ff = CalcNF2FF(nf2ff, Sim_Path, f_rad, theta*pi/180, phi*pi/180, 'Outfile','3D_Pattern.h5', 'Mode', 0,'Verbose',1); %% P_in = 0.5*port{1}.uf.inc .* conj( port{1}.if.inc ); % accepted antenna feed power diff --git a/matlab/Tutorials/Circ_Waveguide.m b/matlab/Tutorials/Circ_Waveguide.m index afa4e34..e70814f 100644 --- a/matlab/Tutorials/Circ_Waveguide.m +++ b/matlab/Tutorials/Circ_Waveguide.m @@ -83,17 +83,17 @@ CSX = AddBox(CSX,'excite',0 ,start,stop); %port 1 start = [mesh.r(1) mesh.a(1) mesh.z(15)]; stop = [mesh.r(end) mesh.a(end) mesh.z(15)]; -CSX = AddProbe(CSX, 'ut1', 10, 1, [], 'ModeFunction',{func_Er,func_Ea,0}); +CSX = AddProbe(CSX, 'ut1', 10, 'ModeFunction',{func_Er,func_Ea,0}); CSX = AddBox(CSX, 'ut1', 0 ,start,stop); -CSX = AddProbe(CSX,'it1', 11, 1, [], 'ModeFunction',{func_Hr,func_Ha,0}); +CSX = AddProbe(CSX,'it1', 11, 'ModeFunction',{func_Hr,func_Ha,0}); CSX = AddBox(CSX,'it1', 0 ,start,stop); %port 2 start(3) = mesh.z(end-14); stop(3) = mesh.z(end-14); -CSX = AddProbe(CSX, 'ut2', 10, 1, [], 'ModeFunction',{func_Er,func_Ea,0}); +CSX = AddProbe(CSX, 'ut2', 10, 'ModeFunction',{func_Er,func_Ea,0}); CSX = AddBox(CSX, 'ut2', 0 ,start,stop); -CSX = AddProbe(CSX,'it2', 11, 1, [], 'ModeFunction',{func_Hr,func_Ha,0}); +CSX = AddProbe(CSX,'it2', 11, 'ModeFunction',{func_Hr,func_Ha,0}); CSX = AddBox(CSX,'it2', 0 ,start,stop); port_dist = mesh.z(end-14) - mesh.z(15); diff --git a/matlab/Tutorials/Rect_Waveguide.m b/matlab/Tutorials/Rect_Waveguide.m index 8a7dd7c..897d3c9 100644 --- a/matlab/Tutorials/Rect_Waveguide.m +++ b/matlab/Tutorials/Rect_Waveguide.m @@ -86,17 +86,17 @@ CSX = AddBox(CSX,'excite',0 ,start,stop); %port 1 start = [mesh.x(1) mesh.y(1) mesh.z(15)]; stop = [mesh.x(end) mesh.y(end) mesh.z(15)]; -CSX = AddProbe(CSX, 'ut1', 10, 1, [], 'ModeFunction',{func_Ex,func_Ey,0}); +CSX = AddProbe(CSX, 'ut1', 10, 'ModeFunction',{func_Ex,func_Ey,0}); CSX = AddBox(CSX, 'ut1', 0 ,start,stop); -CSX = AddProbe(CSX,'it1', 11, 1, [], 'ModeFunction',{func_Hx,func_Hy,0}); +CSX = AddProbe(CSX,'it1', 11, 'ModeFunction',{func_Hx,func_Hy,0}); CSX = AddBox(CSX,'it1', 0 ,start,stop); %port 2 start = [mesh.x(1) mesh.y(1) mesh.z(end-14)]; stop = [mesh.x(end) mesh.y(end) mesh.z(end-14)]; -CSX = AddProbe(CSX, 'ut2', 10, 1, [], 'ModeFunction',{func_Ex,func_Ey,0}); +CSX = AddProbe(CSX, 'ut2', 10, 'ModeFunction',{func_Ex,func_Ey,0}); CSX = AddBox(CSX, 'ut2', 0 ,start,stop); -CSX = AddProbe(CSX,'it2', 11, 1, [], 'ModeFunction',{func_Hx,func_Hy,0}); +CSX = AddProbe(CSX,'it2', 11, 'ModeFunction',{func_Hx,func_Hy,0}); CSX = AddBox(CSX,'it2', 0 ,start,stop); port_dist = mesh.z(end-14) - mesh.z(15); diff --git a/matlab/Tutorials/Simple_Patch_Antenna.m b/matlab/Tutorials/Simple_Patch_Antenna.m index 3948cd0..21a626d 100644 --- a/matlab/Tutorials/Simple_Patch_Antenna.m +++ b/matlab/Tutorials/Simple_Patch_Antenna.m @@ -33,7 +33,6 @@ substrate.cells = 4; %setup feeding feed.pos = -6; %feeding position in x-direction -feed.width = 2; %feeding port width feed.R = 50; %feed resistance % size of the simulation box @@ -78,8 +77,8 @@ stop(3) =0; CSX = AddBox(CSX,'gnd',10,start,stop); %% apply the excitation & resist as a current source -start = [feed.pos-feed.width/2 -feed.width/2 0]; -stop = [feed.pos+feed.width/2 +feed.width/2 substrate.thickness]; +start = [feed.pos 0 0]; +stop = [feed.pos 0 substrate.thickness]; [CSX port] = AddLumpedPort(CSX, 5 ,1 ,feed.R, start, stop, [0 0 1], true); %% finalize the mesh diff --git a/openems.cpp b/openems.cpp index 3ca2899..45c601d 100644 --- a/openems.cpp +++ b/openems.cpp @@ -348,7 +348,7 @@ bool openEMS::SetupProcessing() stop[1] =bnd[3]; stop[2] =bnd[5]; CSPropProbeBox* pb = Probes.at(i)->ToProbeBox(); - Processing* proc = NULL; + ProcessIntegral* proc = NULL; if (pb) { if (pb->GetProbeType()==0) @@ -388,6 +388,7 @@ bool openEMS::SetupProcessing() } proc->SetProcessInterval(Nyquist/m_OverSampling); proc->AddFrequency(pb->GetFDSamples()); + proc->GetNormalDir(pb->GetNormalDir()); if (l_MultiBox==false) proc->SetName(pb->GetName()); else