InitFDTD: API change to key/value only
legacy format is supported Signed-off-by: Thorsten Liebig <thorsten.liebig@gmx.de>pull/1/head
parent
62b2c1124c
commit
e9495ef749
|
@ -1,15 +1,13 @@
|
||||||
function FDTD = InitFDTD(NrTS, endCrit, varargin)
|
function FDTD = InitFDTD(varargin)
|
||||||
% function FDTD = InitFDTD(NrTS, endCrit, varargin)
|
% function FDTD = InitFDTD(varargin)
|
||||||
%
|
%
|
||||||
% Inititalize the FDTD data-structure.
|
% Inititalize the FDTD data-structure.
|
||||||
%
|
%
|
||||||
% optional arguments:
|
|
||||||
% NrTS: max. number of timesteps to simulate (e.g. default=1e9)
|
|
||||||
% endCrit: 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
|
|
||||||
%
|
|
||||||
% optional field arguments for usage with openEMS:
|
% optional field arguments for usage with openEMS:
|
||||||
|
% 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
|
||||||
% OverSampling: nyquist oversampling of time domain dumps
|
% OverSampling: nyquist oversampling of time domain dumps
|
||||||
% CoordSystem: choose coordinate system (0 Cartesian, 1 Cylindrical)
|
% CoordSystem: choose coordinate system (0 Cartesian, 1 Cylindrical)
|
||||||
% TimeStep: force to use a given timestep (dangerous!)
|
% TimeStep: force to use a given timestep (dangerous!)
|
||||||
|
@ -20,33 +18,42 @@ function FDTD = InitFDTD(NrTS, endCrit, varargin)
|
||||||
% FDTD = InitFDTD();
|
% FDTD = InitFDTD();
|
||||||
%
|
%
|
||||||
% %init with 1e6 max. timesteps and -60dB end-criteria
|
% %init with 1e6 max. timesteps and -60dB end-criteria
|
||||||
% FDTD = InitFDTD(1e6, 1e-6);
|
% FDTD = InitFDTD('NrTS', 1e6, 'EndCriteria', 1e-6);
|
||||||
%
|
%
|
||||||
% %cylindrical FDTD simulation
|
% %cylindrical FDTD simulation
|
||||||
% FDTD = InitFDTD(1e6, 1e-6, 'CoordSystem', 1);
|
% FDTD = InitFDTD('CoordSystem', 1);
|
||||||
%
|
%
|
||||||
% See also InitCSX
|
% See also InitCSX
|
||||||
%
|
%
|
||||||
% openEMS matlab interface
|
% openEMS matlab interface
|
||||||
% -----------------------
|
% -----------------------
|
||||||
% author: Thorsten Liebig (c) 2010-2012
|
% author: Thorsten Liebig (c) 2010-2013
|
||||||
|
|
||||||
if (nargin<1)
|
% default values
|
||||||
FDTD.ATTRIBUTE.NumberOfTimesteps=1e9;
|
NrTS = 1e9;
|
||||||
else
|
endCrit = 1e-5;
|
||||||
FDTD.ATTRIBUTE.NumberOfTimesteps=NrTS;
|
|
||||||
end
|
% legacy support
|
||||||
if (nargin<2)
|
if ((nargin==1) && (isnumeric(varargin{1})))
|
||||||
FDTD.ATTRIBUTE.endCriteria = 1e-5;
|
NrTS = varargin{1};
|
||||||
else
|
warning('openEMS:InitFDTD',['Syntax for InitFDTD has changed, use: "InitFDTD(''NrTS'', ' num2str(NrTS) ')" instead! Legacy support enabled.']);
|
||||||
FDTD.ATTRIBUTE.endCriteria=endCrit;
|
elseif ((nargin==2) && (isnumeric(varargin{1})) && (isnumeric(varargin{2})))
|
||||||
|
NrTS = varargin{1};
|
||||||
|
endCrit = varargin{2};
|
||||||
|
warning('openEMS:InitFDTD',['Syntax for InitFDTD has changed, use: "InitFDTD(''NrTS'', ' num2str(NrTS) ', ''EndCriteria'', ' num2str(endCrit) ')" instead! Legacy support enabled.']);
|
||||||
end
|
end
|
||||||
|
|
||||||
for n=1:numel(varargin)/2
|
for n=1:numel(varargin)/2
|
||||||
if strcmp(varargin{2*n-1},'CoordSystem')==1
|
if strcmpi(varargin{2*n-1},'CoordSystem')==1
|
||||||
FDTD.ATTRIBUTE.CylinderCoords=varargin{2*n}==1;
|
FDTD.ATTRIBUTE.CylinderCoords=varargin{2*n}==1;
|
||||||
|
elseif strcmpi(varargin{2*n-1},'NrTS')==1
|
||||||
|
NrTS=varargin{2*n};
|
||||||
|
elseif strcmpi(varargin{2*n-1},'EndCriteria')==1
|
||||||
|
endCrit=varargin{2*n};
|
||||||
else
|
else
|
||||||
FDTD.ATTRIBUTE.(varargin{2*n-1})=varargin{2*n};
|
FDTD.ATTRIBUTE.(varargin{2*n-1})=varargin{2*n};
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
FDTD.ATTRIBUTE.NumberOfTimesteps=NrTS;
|
||||||
|
FDTD.ATTRIBUTE.endCriteria=endCrit;
|
||||||
|
|
Loading…
Reference in New Issue