Skip to content

Commit f47f520

Browse files
committed
Fixed bug with 0 area gaussian pulse
1 parent 6b59a26 commit f47f520

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/GRAPE.m

+8-5
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@
430430

431431
PulsePhaseRotate[pulse_,\[Phi]_]:=
432432
Module[{xy=pulse[Pulse],a\[Theta]},
433-
a\[Theta]={Norm/@xy,\[Phi]+(ArcTan[First@#,Last@#]&/@xy)}\[Transpose];
433+
a\[Theta]={Norm/@xy,\[Phi]+(If[First@#==0&&Last@#==0,0,ArcTan[First@#,Last@#]]&/@xy)}\[Transpose];
434434
xy={First[#]Cos[Last@#],First[#]Sin[Last@#]}&/@a\[Theta];
435435
PulseReplaceKey[pulse,Pulse,xy]
436436
]
@@ -486,10 +486,13 @@
486486
Module[{\[Sigma],NI,fun,pulse},
487487
\[Sigma]=riseTime/3;
488488
fun[t_]:=Piecewise[{{1,riseTime<t<T-riseTime},{Exp[-(t-riseTime)^2/(2\[Sigma]^2)],t<=riseTime},{Exp[-(t-T+riseTime)^2/(2\[Sigma]^2)],t>=T-riseTime}}];
489-
NI=NIntegrate[fun[t],{t,0,T}];
490-
pulse=Table[{area*fun[t-dt/2]/NI,0},{t,0,T,dt}];
491-
(*Correct the area now that we have a descent shape*)
492-
pulse=area*pulse/(dt*Total@Flatten@pulse);
489+
If[area!=0,
490+
NI=NIntegrate[fun[t],{t,0,T}];
491+
pulse=Table[{area*fun[t-dt/2]/NI,0},{t,0,T,dt}];
492+
(*Correct the area now that we have a descent shape*)
493+
pulse=area*pulse/(dt*Total@Flatten@pulse);,
494+
pulse=Table[{0,0},{t,0,T,dt}];
495+
];
493496
AddTimeSteps[dt, pulse]
494497
];
495498
GaussianTailsPulse[dt_,T_,riseTime_,Max->max_]:=Module[

0 commit comments

Comments
 (0)