Code covered by the BSD License  

Highlights from
Interactive Simulation Toolbox for Optics

image thumbnail

Interactive Simulation Toolbox for Optics

by

 

30 Jan 2013 (Updated )

2-dimensional FDTD-Toolbox (Yee Grid,Matrix based,current like sources,PML boundaries, GUI based)

Startsimulation
function Startsimulation
%This function is for the defnition of the visualization parameters for the
% simulation - (the function is called by
%clicking - 'Start Simulation')
global check scrsz x y dx X Y backgroundeps backgroundmu epsilon mu ZS Anz epsilon0 mu0 alphadat pmlwidth source answerSim scalefactor2
answerSim{8}=num2str(scalefactor2);
scrsz= get(gcf,'outerposition');
if check==1
    errordlg('There is an unconfirmed Structure')
    return
end
prompt={'Visualization Hx=1, Hy=2, Ez=3, |H|=4, |E|=5, |S|=6',...
    'Visualization after which number of timesteps ',...
    'Create Movie',...
    'Movie-/Filename',...
    'Frame Rate',...
    'Create File with Fieldvalues',...
    'Show PMLs',...
    'Brightness',...
    'Define Own Colormap - 1 for Yes, 0 for No',...
    'Own Colormap'};


name='Visualization';
numlines=1;
defaultanswer=answerSim;
options.Resize='on';
options.WindowStyle='normal';
options.Interpreter='tex';
options.fonsize=20;

answerSim2=inputdlg(prompt,name,numlines,defaultanswer,options);
if isempty(answerSim2)
    return
end
answerSim=answerSim2;
plotvar{1}=str2num(answerSim{2});
plotvar{2}=str2num(answerSim{1});
plotvar{3}=str2num(answerSim{3});
plotvar{4}=answerSim{4};
plotvar{5}=str2num(answerSim{7+1});
plotvar{6}=str2num(answerSim{5+1});
plotvar{8}=str2num(answerSim{8+1});
plotvar{9}=str2num(answerSim{9+1});
plotvar{10}=str2num(answerSim{5});

Anzeige=str2num(answerSim{6+1});
switch Anzeige
    case 0
        Anz=pmlwidth+1;
    case 1
        Anz=1;
end





%%
%PML Vorkehrungen
dx=x(2)-x(1);
dy=y(2)-y(1);

x=linspace(-max(x)-pmlwidth*dx,max(x)+pmlwidth*dx,length(x)+2*pmlwidth);
y=linspace(-max(y)-pmlwidth*dy,max(y)+pmlwidth*dy,length(y)+2*pmlwidth);


[X,Y]=meshgrid(x,y);

epsilon=pmlerw(epsilon,pmlwidth);
mu=pmlerw(mu,pmlwidth);
a=size(source);
for j=1:a(1)
    source{j,1}=pmlerw(source{j,1},pmlwidth);
end


%%
pml.Anz=Anz;
pml.weite=pmlwidth;

fdtd(X,Y,epsilon,mu,source,ZS,pml,plotvar)
refreshstructure

Contact us