From 962fe5ee94f62778872ab2caecaff9490f9366a4 Mon Sep 17 00:00:00 2001 From: Thorsten Liebig Date: Mon, 22 Mar 2010 23:15:04 +0100 Subject: [PATCH] Initial matlab interface --- matlab/InitFDTD.m | 7 +++++++ matlab/SetBoundaryCond.m | 8 ++++++++ matlab/SetGaussExcite.m | 5 +++++ matlab/WriteOpenEMS.m | 6 ++++++ matlab/examples/Helix.m | 34 ++++++++++++++++++++++++++++++++++ 5 files changed, 60 insertions(+) create mode 100644 matlab/InitFDTD.m create mode 100644 matlab/SetBoundaryCond.m create mode 100644 matlab/SetGaussExcite.m create mode 100644 matlab/WriteOpenEMS.m create mode 100644 matlab/examples/Helix.m diff --git a/matlab/InitFDTD.m b/matlab/InitFDTD.m new file mode 100644 index 0000000..516c6ab --- /dev/null +++ b/matlab/InitFDTD.m @@ -0,0 +1,7 @@ +function FDTD = InitFDTD(NrTS, endCrit) + +FDTD.ATTRIBUTE.NumberOfTimesteps=NrTS; +FDTD.ATTRIBUTE.endCriteria=endCrit; + + + diff --git a/matlab/SetBoundaryCond.m b/matlab/SetBoundaryCond.m new file mode 100644 index 0000000..6d1ba6d --- /dev/null +++ b/matlab/SetBoundaryCond.m @@ -0,0 +1,8 @@ +function FDTD = SetBoundaryCond(FDTD,BC) + +FDTD.BoundaryCond.ATTRIBUTE.xmin=BC(1); +FDTD.BoundaryCond.ATTRIBUTE.xmax=BC(2); +FDTD.BoundaryCond.ATTRIBUTE.ymin=BC(3); +FDTD.BoundaryCond.ATTRIBUTE.ymax=BC(4); +FDTD.BoundaryCond.ATTRIBUTE.zmin=BC(5); +FDTD.BoundaryCond.ATTRIBUTE.zmax=BC(6); diff --git a/matlab/SetGaussExcite.m b/matlab/SetGaussExcite.m new file mode 100644 index 0000000..a5f624e --- /dev/null +++ b/matlab/SetGaussExcite.m @@ -0,0 +1,5 @@ +function FDTD = SetGaussExcite(FDTD,f0,fc); + +FDTD.Excitation.ATTRIBUTE.Type=0; +FDTD.Excitation.ATTRIBUTE.f0=f0; +FDTD.Excitation.ATTRIBUTE.fc=fc; \ No newline at end of file diff --git a/matlab/WriteOpenEMS.m b/matlab/WriteOpenEMS.m new file mode 100644 index 0000000..f5569c1 --- /dev/null +++ b/matlab/WriteOpenEMS.m @@ -0,0 +1,6 @@ +function WriteOpenEMS(filename, FDTD, CSX) + +openEMS.FDTD=FDTD; +openEMS.ContinuousStructure=CSX; + +xml_write(filename,openEMS); \ No newline at end of file diff --git a/matlab/examples/Helix.m b/matlab/examples/Helix.m new file mode 100644 index 0000000..febf320 --- /dev/null +++ b/matlab/examples/Helix.m @@ -0,0 +1,34 @@ +close all; +clear all; +clc + +openEMS_Path = [pwd() '/../../'] +openEMS_opts = ''; +openEMS_opts = [openEMS_opts ' --disable-dumps']; +openEMS_opts = [openEMS_opts ' --debug-material']; + +Sim_Path = 'tmp'; +Sim_CSX = 'helix.xml'; + +mkdir(Sim_Path); + +%setup FDTD parameter +FDTD = InitFDTD(1000,1e-6); +FDTD = SetGaussExcite(FDTD,0.5e9,0.5e9); +BC = [1 1 1 1 1 1]; +FDTD = SetBoundaryCond(FDTD,BC); + +%setup CSXCAD geometry +CSX = []; + +%Write openEMS compatoble xml-file +WriteOpenEMS([Sim_Path '/' Sim_CSX],FDTD,CSX); + +%cd to working dir and run openEMS +savePath = pwd(); +cd(Sim_Path); %cd to working dir +command = [openEMS_Path 'openEMS ' openEMS_opts]; +disp(command); +system(command) +cd(savePath); +