From 677bbe534cf3aec3640932e2415a633b05a1df78 Mon Sep 17 00:00:00 2001 From: Frederic Tessier Date: Mon, 5 Mar 2018 12:02:00 -0500 Subject: [PATCH] Fix #413: limit vacuum step size in magnetic field Adjust the charged particle step routine for transport in vacuum when there is an electromagnetic field (emf). The existing logic failed because the emf step size restriction was not taken into account before the howfar call. Hence the howfar method tracked the particle in a single straight step across the entire vacuum region, causing erroneous region changes and discards. Also check if the particle in fact entered a new region before calling the macro to change the region, since charged particle may take many steps through a vacuum region when there is a field. Remove redundant step size restriction code in the vacuum emf transport macro, now that the field step size restriction in vacuum has been moved ahead of howfar in the electr subroutine. --- HEN_HOUSE/src/egsnrc.mortran | 6 +++++- HEN_HOUSE/src/emf_macros.mortran | 10 +--------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/HEN_HOUSE/src/egsnrc.mortran b/HEN_HOUSE/src/egsnrc.mortran index c566c58fb..44afcfb3a 100644 --- a/HEN_HOUSE/src/egsnrc.mortran +++ b/HEN_HOUSE/src/egsnrc.mortran @@ -1111,6 +1111,10 @@ $start_new_particle; " direction of motion at the start of the step " Note that tustep and ustep are modified below. " The above provide defaults.) + + " EM field step size restriction in vacuum + $SET-TUSTEP-EM-FIELD; + ustep = tustep; ] ELSE [ @@ -1383,7 +1387,7 @@ $start_new_particle; "(allows for EM field deflection ] "end of vacuum step - $electron_region_change; + IF(irnew ~= irold) [ $electron_region_change; ]; IF(ustep ~= 0) [$AUSCALL($TRANAUSA);] IF(eie <= ecut(irl)) [go to :ECUT-DISCARD:;] diff --git a/HEN_HOUSE/src/emf_macros.mortran b/HEN_HOUSE/src/emf_macros.mortran index 74d962259..4fab00fa8 100644 --- a/HEN_HOUSE/src/emf_macros.mortran +++ b/HEN_HOUSE/src/emf_macros.mortran @@ -88,7 +88,7 @@ APPEND {; ufx,ufy,ufz, bdotub,bsqrd, ufxpar,ufypar,ufzpar, - ufxprp,ufyprp,ufzprp,ustepold; + ufxprp,ufyprp,ufzprp; } TO {$DEFINE-LOCAL-VARIABLES-ELECTR;}; @@ -291,14 +291,6 @@ IF(MEDIUM.EQ.0)[ "$SET-TVSTEP-EM-FIELD;--this is for higher order corrections" "do first order corrections for now--BW" IF(ExIN~=0.0 | EyIN~=0.0 | EzIN~=0.0 | BxIN~=0.0 | ByIN~=0.0 | BzIN~=0)[ -USTEPOLD=USTEP; -IF(USTEP>smaxir(irl)) USTEP=smaxir(irl); -TUSTEP=USTEP; -$SET-TUSTEP-EM-FIELD; -TVSTEP=TUSTEP; -VSTEP=TVSTEP; -USTEP=VSTEP; -IF(USTEP