diff --git a/Analyse/PlotVoltage.m b/Analyse/PlotVoltage.m index 02cec09..7422055 100644 --- a/Analyse/PlotVoltage.m +++ b/Analyse/PlotVoltage.m @@ -17,11 +17,11 @@ ylabel('ut_1 \rightarrow'); grid on; dt=t(2)-t(1); -u= [u ; zeros(size(u))]; +u= [u ; zeros(5000,1)]; L=numel(u); t = (1:L)*dt; -f = (1:L)/L/dt; +f = (0:L-1)/L/dt; fu = fft(u)/L; subplot(2,2,2); title('u_1 FD'); @@ -42,10 +42,10 @@ ylabel('it_1 \rightarrow'); grid on; dt=t(2)-t(1); -i = [i; zeros(size(t))]; +i = [i; zeros(5000,1)]; L=numel(i); t = (1:L)*dt; -f = (1:L)/L/dt; +f = (0:L-1)/L/dt; fi = fft(i)/L; subplot(2,2,4); @@ -56,8 +56,13 @@ ylabel('|if_1| \rightarrow'); grid on; figure(2); +subplot(2,1,1); plot(f,real(fu./fi)); xlim([0 1e9]); grid on; +subplot(2,1,2); +plot(f,imag(fu./fi)); +xlim([0 1e9]); +grid on; diff --git a/examples/FDTD_examples.cpp b/examples/FDTD_examples.cpp index b734946..48d963e 100644 --- a/examples/FDTD_examples.cpp +++ b/examples/FDTD_examples.cpp @@ -248,7 +248,7 @@ void BuildPlaneWave(const char* filename) void BuildMSL(const char* filename) { - int maxIter = 1000; + int maxIter = 10000; double f0=0.5e9; double fc=0.5e9; int Excit_Type=0; @@ -599,7 +599,7 @@ void BuildCoaxial_Cartesian(const char* filename) void BuildHelix(const char* filename) { - int maxIter = 1e5; + int maxIter = 5e5; double f0=0.5e9; double fc=0.5e9; int Excit_Type=0; @@ -614,7 +614,6 @@ void BuildHelix(const char* filename) double coil_length = 50; double delta[] = {0.5,0.5,0.5}; - //MSL CSPropMaterial* copper = new CSPropMaterial(CSX.GetParameterSet()); copper->SetKappa(56e6); copper->SetName("copper"); @@ -622,7 +621,7 @@ void BuildHelix(const char* filename) CSPrimUserDefined* helix = new CSPrimUserDefined(CSX.GetParameterSet(),copper); helix->SetCoordSystem(CSPrimUserDefined::CYLINDER_SYSTEM); - helix->SetFunction("(r>9)&(r<11)&(sqrt(pow(x-r*cos(2*pi*z/6.25),2)+pow(y-r*sin(2*pi*z/6.25),2))<2)&(z>0)&(z<50)"); + helix->SetFunction("(r>9.3)&(r<10.7)&(sqrt(pow(x-r*cos(2*pi*z/6.25),2)+pow(y-r*sin(2*pi*z/6.25),2))<1.4)&(z>0)&(z<50)"); CSX.AddPrimitive(helix); CSPrimCylinder* cyl = new CSPrimCylinder(CSX.GetParameterSet(),copper); cyl->SetRadius(wire_rad); @@ -670,15 +669,15 @@ void BuildHelix(const char* filename) CSPropDumpBox* Edump = NULL; CSPrimBox* box = NULL; //E-field dump xz -// Edump = new CSPropDumpBox(CSX.GetParameterSet()); -// Edump->SetDumpType(0); -// Edump->SetName("Et_xz_"); -// CSX.AddProperty(Edump); -// box = new CSPrimBox(CSX.GetParameterSet(),Edump); -// box->SetCoord(0,coil_rad/-2.0-25.0);box->SetCoord(1,coil_rad/2.0+25.0+feed_length); -// box->SetCoord(2,0.0);box->SetCoord(3,0.0); -// box->SetCoord(4,-25.0);box->SetCoord(5,coil_length+25.0); -// CSX.AddPrimitive(box); + Edump = new CSPropDumpBox(CSX.GetParameterSet()); + Edump->SetDumpType(0); + Edump->SetName("Et_xz_"); + CSX.AddProperty(Edump); + box = new CSPrimBox(CSX.GetParameterSet(),Edump); + box->SetCoord(0,coil_rad/-1.0-25.0);box->SetCoord(1,coil_rad/1.0+25.0+feed_length); + box->SetCoord(2,0.0);box->SetCoord(3,0.0); + box->SetCoord(4,-25.0);box->SetCoord(5,coil_length+25.0); + CSX.AddPrimitive(box); // // //E-field dump xy // Edump = new CSPropDumpBox(CSX.GetParameterSet()); @@ -728,13 +727,50 @@ void BuildHelix(const char* filename) CSRectGrid* grid = CSX.GetGrid(); - for (double n=coil_rad/-2.0-25.0;n<=coil_rad/2.0+25.0+feed_length;n+=delta[0]) + double offset[]={coil_rad/-1.0,coil_rad/-1.0,0.0}; + //graded mesh + for (int n=0;n<3;++n) + { + grid->AddDiscLine(n,offset[n] - 25.0); + grid->AddDiscLine(n,offset[n] - 15.0); + grid->AddDiscLine(n,offset[n] - 10.0); + grid->AddDiscLine(n,offset[n] - 5.0); + grid->AddDiscLine(n,offset[n] - 2.0); + grid->AddDiscLine(n,offset[n] - 1.0); + grid->AddDiscLine(n,offset[n] - 0.5); + } + + for (double n=coil_rad/-1.0;n<=coil_rad;n+=delta[0]) grid->AddDiscLine(0,n); - for (double n=coil_rad/-2.0-25.0;n<=coil_rad/2.0+25.0;n+=delta[1]) + //feeding mesh + grid->AddDiscLine(0,coil_rad+0.5); + grid->AddDiscLine(0,coil_rad+1); + grid->AddDiscLine(0,coil_rad+2); + grid->AddDiscLine(0,coil_rad+5); + grid->AddDiscLine(0,coil_rad+7); + grid->AddDiscLine(0,coil_rad+9); + grid->AddDiscLine(0,coil_rad+9.5); + grid->AddDiscLine(0,coil_rad+10); + for (double n=coil_rad/-1.0;n<=coil_rad;n+=delta[1]) grid->AddDiscLine(1,n); - for (double n=-25.0;n<=coil_length+25.0;n+=delta[2]) + for (double n=0.0;n<=coil_length;n+=delta[2]) grid->AddDiscLine(2,n); + offset[0]=coil_rad+feed_length; + offset[1]=coil_rad; + offset[2]=coil_length; + for (int n=0;n<3;++n) + { + grid->AddDiscLine(n,offset[n] + 0.5); + grid->AddDiscLine(n,offset[n] + 1.0); + grid->AddDiscLine(n,offset[n] + 2.0); + grid->AddDiscLine(n,offset[n] + 5.0); + grid->AddDiscLine(n,offset[n] + 10.0); + grid->AddDiscLine(n,offset[n] + 15.0); + grid->AddDiscLine(n,offset[n] + 25.0); + grid->Sort(n); + } + grid->SetDeltaUnit(1e-3); //*************** Create XML file ********************** diff --git a/examples/Helix.xml b/examples/Helix.xml index df151bb..e6fb18d 100644 --- a/examples/Helix.xml +++ b/examples/Helix.xml @@ -1,14 +1,14 @@ - + - -30,-29.5,-29,-28.5,-28,-27.5,-27,-26.5,-26,-25.5,-25,-24.5,-24,-23.5,-23,-22.5,-22,-21.5,-21,-20.5,-20,-19.5,-19,-18.5,-18,-17.5,-17,-16.5,-16,-15.5,-15,-14.5,-14,-13.5,-13,-12.5,-12,-11.5,-11,-10.5,-10,-9.5,-9,-8.5,-8,-7.5,-7,-6.5,-6,-5.5,-5,-4.5,-4,-3.5,-3,-2.5,-2,-1.5,-1,-0.5,0,0.5,1,1.5,2,2.5,3,3.5,4,4.5,5,5.5,6,6.5,7,7.5,8,8.5,9,9.5,10,10.5,11,11.5,12,12.5,13,13.5,14,14.5,15,15.5,16,16.5,17,17.5,18,18.5,19,19.5,20,20.5,21,21.5,22,22.5,23,23.5,24,24.5,25,25.5,26,26.5,27,27.5,28,28.5,29,29.5,30,30.5,31,31.5,32,32.5,33,33.5,34,34.5,35,35.5,36,36.5,37,37.5,38,38.5,39,39.5,40 - -30,-29.5,-29,-28.5,-28,-27.5,-27,-26.5,-26,-25.5,-25,-24.5,-24,-23.5,-23,-22.5,-22,-21.5,-21,-20.5,-20,-19.5,-19,-18.5,-18,-17.5,-17,-16.5,-16,-15.5,-15,-14.5,-14,-13.5,-13,-12.5,-12,-11.5,-11,-10.5,-10,-9.5,-9,-8.5,-8,-7.5,-7,-6.5,-6,-5.5,-5,-4.5,-4,-3.5,-3,-2.5,-2,-1.5,-1,-0.5,0,0.5,1,1.5,2,2.5,3,3.5,4,4.5,5,5.5,6,6.5,7,7.5,8,8.5,9,9.5,10,10.5,11,11.5,12,12.5,13,13.5,14,14.5,15,15.5,16,16.5,17,17.5,18,18.5,19,19.5,20,20.5,21,21.5,22,22.5,23,23.5,24,24.5,25,25.5,26,26.5,27,27.5,28,28.5,29,29.5,30 - -25,-24.5,-24,-23.5,-23,-22.5,-22,-21.5,-21,-20.5,-20,-19.5,-19,-18.5,-18,-17.5,-17,-16.5,-16,-15.5,-15,-14.5,-14,-13.5,-13,-12.5,-12,-11.5,-11,-10.5,-10,-9.5,-9,-8.5,-8,-7.5,-7,-6.5,-6,-5.5,-5,-4.5,-4,-3.5,-3,-2.5,-2,-1.5,-1,-0.5,0,0.5,1,1.5,2,2.5,3,3.5,4,4.5,5,5.5,6,6.5,7,7.5,8,8.5,9,9.5,10,10.5,11,11.5,12,12.5,13,13.5,14,14.5,15,15.5,16,16.5,17,17.5,18,18.5,19,19.5,20,20.5,21,21.5,22,22.5,23,23.5,24,24.5,25,25.5,26,26.5,27,27.5,28,28.5,29,29.5,30,30.5,31,31.5,32,32.5,33,33.5,34,34.5,35,35.5,36,36.5,37,37.5,38,38.5,39,39.5,40,40.5,41,41.5,42,42.5,43,43.5,44,44.5,45,45.5,46,46.5,47,47.5,48,48.5,49,49.5,50,50.5,51,51.5,52,52.5,53,53.5,54,54.5,55,55.5,56,56.5,57,57.5,58,58.5,59,59.5,60,60.5,61,61.5,62,62.5,63,63.5,64,64.5,65,65.5,66,66.5,67,67.5,68,68.5,69,69.5,70,70.5,71,71.5,72,72.5,73,73.5,74,74.5,75 + -35,-25,-20,-15,-12,-11,-10.5,-10,-9.5,-9,-8.5,-8,-7.5,-7,-6.5,-6,-5.5,-5,-4.5,-4,-3.5,-3,-2.5,-2,-1.5,-1,-0.5,0,0.5,1,1.5,2,2.5,3,3.5,4,4.5,5,5.5,6,6.5,7,7.5,8,8.5,9,9.5,10,10.5,11,12,15,17,19,19.5,20,20.5,21,22,25,30,35,45 + -35,-25,-20,-15,-12,-11,-10.5,-10,-9.5,-9,-8.5,-8,-7.5,-7,-6.5,-6,-5.5,-5,-4.5,-4,-3.5,-3,-2.5,-2,-1.5,-1,-0.5,0,0.5,1,1.5,2,2.5,3,3.5,4,4.5,5,5.5,6,6.5,7,7.5,8,8.5,9,9.5,10,10.5,11,12,15,20,25,35 + -25,-15,-10,-5,-2,-1,-0.5,0,0.5,1,1.5,2,2.5,3,3.5,4,4.5,5,5.5,6,6.5,7,7.5,8,8.5,9,9.5,10,10.5,11,11.5,12,12.5,13,13.5,14,14.5,15,15.5,16,16.5,17,17.5,18,18.5,19,19.5,20,20.5,21,21.5,22,22.5,23,23.5,24,24.5,25,25.5,26,26.5,27,27.5,28,28.5,29,29.5,30,30.5,31,31.5,32,32.5,33,33.5,34,34.5,35,35.5,36,36.5,37,37.5,38,38.5,39,39.5,40,40.5,41,41.5,42,42.5,43,43.5,44,44.5,45,45.5,46,46.5,47,47.5,48,48.5,49,49.5,50,50.5,51,52,55,60,65,75 @@ -38,19 +38,26 @@ - + - - + + + + + + + + + - (r>9)&(r<11)&(sqrt(pow(x-r*cos(2*pi*z/6.25),2)+pow(y-r*sin(2*pi*z/6.25),2))<2)&(z>0)&(z<50) + (r>9.3)&(r<10.7)&(sqrt(pow(x-r*cos(2*pi*z/6.25),2)+pow(y-r*sin(2*pi*z/6.25),2))<1.4)&(z>0)&(z<50) @@ -73,10 +80,14 @@ + + + + - + diff --git a/examples/MSL.xml b/examples/MSL.xml index 3d99f45..d8602bc 100644 --- a/examples/MSL.xml +++ b/examples/MSL.xml @@ -1,6 +1,6 @@ - +