2013-02-17 10:06:49 +00:00
function FDTD = InitFDTD ( varargin)
% function FDTD = InitFDTD(varargin)
2010-04-07 14:31:35 +00:00
%
2022-03-11 21:17:27 +00:00
% Initialize the FDTD data-structure.
2012-01-17 09:23:13 +00:00
%
% optional field arguments for usage with openEMS:
2013-02-17 10:06:49 +00:00
% NrTS: max. number of timesteps to simulate (e.g. default=1e9)
% EndCriteria: end criteria, e.g. 1e-5, simulations stops if energy has
% decayed by this value (<1e-4 is recommended, default=1e-5)
% MaxTime: max. real time in seconds to simulate
2010-04-07 14:31:35 +00:00
% OverSampling: nyquist oversampling of time domain dumps
2012-01-16 09:12:01 +00:00
% CoordSystem: choose coordinate system (0 Cartesian, 1 Cylindrical)
2013-08-29 07:43:16 +00:00
% MultiGrid: define a cylindrical sub-grid radius
2012-09-27 12:20:20 +00:00
% TimeStep: force to use a given timestep (dangerous!)
% TimeStepFactor: reduce the timestep by a given factor (>0 to <=1)
2013-03-27 10:58:24 +00:00
% TimeStepMethod: 1 or 3 chose timestep method (1=CFL, 3=Rennigs (default))
2013-02-18 09:38:55 +00:00
% CellConstantMaterial: set to 1 to assume a material is constant inside
% a cell (material probing in cell center)
2010-04-07 14:31:35 +00:00
%
2012-01-17 09:23:13 +00:00
% examples:
% %default init with 1e9 max. timesteps and -50dB end-criteria
% FDTD = InitFDTD();
%
% %init with 1e6 max. timesteps and -60dB end-criteria
2013-02-17 10:06:49 +00:00
% FDTD = InitFDTD('NrTS', 1e6, 'EndCriteria', 1e-6);
2012-01-17 09:23:13 +00:00
%
% %cylindrical FDTD simulation
2013-02-17 10:06:49 +00:00
% FDTD = InitFDTD('CoordSystem', 1);
2012-01-17 09:23:13 +00:00
%
% See also InitCSX
2010-04-07 14:31:35 +00:00
%
% openEMS matlab interface
% -----------------------
2013-02-17 10:06:49 +00:00
% author: Thorsten Liebig (c) 2010-2013
2010-03-22 22:15:04 +00:00
2013-02-17 10:06:49 +00:00
% default values
NrTS = 1e9 ;
endCrit = 1e-5 ;
% legacy support
if ( ( nargin == 1 ) && ( isnumeric ( varargin { 1 } ) ) )
NrTS = varargin { 1 } ;
warning ( ' openEMS:InitFDTD' , [ ' Syntax for InitFDTD has changed, use: "InitFDTD(' ' NrTS' ' , ' num2str ( NrTS ) ' )" instead! Legacy support enabled.' ] ) ;
2013-03-01 08:13:53 +00:00
elseif ( ( nargin > 1 ) && ( isnumeric ( varargin { 1 } ) ) && ( isnumeric ( varargin { 2 } ) ) )
2013-02-17 10:06:49 +00:00
NrTS = varargin { 1 } ;
endCrit = varargin { 2 } ;
2013-03-01 08:13:53 +00:00
varargin ( 1 : 2 ) = [ ] ;
2013-02-17 10:06:49 +00:00
warning ( ' openEMS:InitFDTD' , [ ' Syntax for InitFDTD has changed, use: "InitFDTD(' ' NrTS' ' , ' num2str ( NrTS ) ' , ' ' EndCriteria' ' , ' num2str ( endCrit ) ' )" instead! Legacy support enabled.' ] ) ;
2012-01-17 09:23:13 +00:00
end
2010-03-22 22:15:04 +00:00
2012-01-16 09:12:01 +00:00
for n = 1 : numel ( varargin ) / 2
2013-02-17 10:06:49 +00:00
if strcmpi ( varargin { 2 * n - 1 } , ' CoordSystem' ) == 1
2012-01-16 09:12:01 +00:00
FDTD . ATTRIBUTE . CylinderCoords = varargin { 2 * n } == 1 ;
2013-02-17 10:06:49 +00:00
elseif strcmpi ( varargin { 2 * n - 1 } , ' NrTS' ) == 1
NrTS = varargin { 2 * n } ;
elseif strcmpi ( varargin { 2 * n - 1 } , ' EndCriteria' ) == 1
endCrit = varargin { 2 * n } ;
2012-01-16 09:12:01 +00:00
else
FDTD . ATTRIBUTE . ( varargin { 2 * n - 1 } ) = varargin { 2 * n } ;
end
2010-04-04 17:48:36 +00:00
end
2010-03-22 22:15:04 +00:00
2013-02-17 10:06:49 +00:00
FDTD . ATTRIBUTE . NumberOfTimesteps = NrTS ;
FDTD . ATTRIBUTE . endCriteria = endCrit ;