From 28c2ae1e8551b4249bed0113b3c98404210f584b Mon Sep 17 00:00:00 2001 From: James Molson Date: Mon, 24 Feb 2020 14:44:11 +0100 Subject: [PATCH 1/5] Add some missing return cases for FLUKA (where FLUKAIO will not return -1) --- source/main_cr.f90 | 4 ++-- source/mod_fluka.f90 | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/source/main_cr.f90 b/source/main_cr.f90 index d6a25bbb3..6b082e455 100644 --- a/source/main_cr.f90 +++ b/source/main_cr.f90 @@ -1185,7 +1185,7 @@ program maincr fluka_con = fluka_init_max_uid( napx ) if(fluka_con < 0) then - write(lerr,"(a,i0,a)") "FLUKA> ERROR Failed to send napx ",napx," to fluka " + write(lerr,"(a,i0,a,i0,a)") "FLUKA> ERROR ", fluka_con, ": Failed to send napx ",napx," to fluka " write(fluka_log_unit, *) "# failed to send napx to fluka ",napx call prror end if @@ -1210,7 +1210,7 @@ program maincr fluka_con = fluka_set_synch_part( e0, e0f, nucm0, aa0, zz0, qq0) if(fluka_con < 0) then - write(lerr,"(a)") "FLUKA> ERROR Failed to update the reference particle" + write(lerr,"(a,i0,a)") "FLUKA> ERROR ", fluka_con, ": Failed to update the reference particle" write(fluka_log_unit,*) "# failed to update ref particle" call prror end if diff --git a/source/mod_fluka.f90 b/source/mod_fluka.f90 index 38e8cf232..2c5b9f9e2 100644 --- a/source/mod_fluka.f90 +++ b/source/mod_fluka.f90 @@ -414,7 +414,7 @@ integer function fluka_send(turn, ipt, el, npart, xv1, xv2, yv1, yv2, s, etot, a if(n.lt.0) then write(fluka_log_unit,'(A,i0,A)') "# FlukaIO error: ", n, " - Error sending Insertion Point" fluka_cid = -1 - fluka_send = -1 + fluka_send = n return end if fluka_last_sent_mess=FLUKA_IPT @@ -593,7 +593,7 @@ integer function fluka_receive(turn, ipt, el, napx, xv1, xv2, yv1, yv2, s, etot, if(n.lt.0) then write(fluka_log_unit,'(A,i0,A)') "# FlukaIO error: ", n ," - Server timed out while waiting for message" fluka_cid = -1 - fluka_receive = -1 + fluka_receive = n return end if From 94188c295cdbe708f1ddcd6a58a60e36347f16a1 Mon Sep 17 00:00:00 2001 From: James Molson Date: Mon, 24 Feb 2020 14:45:59 +0100 Subject: [PATCH 2/5] Add mass tolerance for geant4 mass differences. --- source/g4collimation/CollimationParticleGun.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/source/g4collimation/CollimationParticleGun.cpp b/source/g4collimation/CollimationParticleGun.cpp index f2ac10631..0aa105aad 100644 --- a/source/g4collimation/CollimationParticleGun.cpp +++ b/source/g4collimation/CollimationParticleGun.cpp @@ -82,7 +82,8 @@ void CollimationParticleGun::SetParticleDetails(double x, double y, double px, d ParticleGun->SetParticleCharge(q*CLHEP::eplus); } const G4double mp = particle->GetPDGMass(); - if(mp != mass) + + if(fabs(mp - mass) > (1e-5*mass)) { std::cout.precision(17); std::cout << "GEANT4> Mass missmatch between Geant4 and SixTrack!" << std::endl; @@ -92,6 +93,16 @@ void CollimationParticleGun::SetParticleDetails(double x, double y, double px, d std::cout << "GEANT4> If the HION block is used, convert to GeV!" << std::endl; exit(EXIT_FAILURE); } + else + { + //scale mass +/* + * From FLUKA coupling: + ECBEAM = (ECBEAM/AMBEAM)*AM(IONID) + AMBEAM = AM(IONID) +*/ + e = (e/mass)*mp; + } //The kinetic energy (Total energy - rest mass) ParticleGun->SetParticleEnergy(e - mp); From 85ad74d723869aa7efba297334f2bac3ecc5d150 Mon Sep 17 00:00:00 2001 From: James Molson Date: Tue, 25 Feb 2020 11:21:13 +0100 Subject: [PATCH 3/5] Delete fluka_init_brhono at Alessio's request. --- source/mod_fluka.f90 | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/source/mod_fluka.f90 b/source/mod_fluka.f90 index 2c5b9f9e2..18b902651 100644 --- a/source/mod_fluka.f90 +++ b/source/mod_fluka.f90 @@ -30,7 +30,6 @@ module mod_fluka public :: fluka_set_synch_part public :: fluka_init_max_uid public :: fluka_is_running - public :: fluka_init_brhono public :: fluka_close @@ -760,26 +759,6 @@ integer function fluka_init_max_uid( npart ) end function fluka_init_max_uid - !---------------------------------------------------------------------------- - ! set Brho nominal - integer function fluka_init_brhono( brhono ) - implicit none - - ! interface variables - real(kind=real64) :: brhono - - ! Auxiliary variables - integer :: n - - n = ntsendbrhono(fluka_cid, brhono) - if (n .lt. 0) then - fluka_init_brhono = -1 - return - end if - - end function fluka_init_brhono - - !---------------------------------------------------------------------------- ! check if fluka is running, ie if it created the integer function fluka_is_running() From 73a89427887842fc82aafacf00a34b91e6215b47 Mon Sep 17 00:00:00 2001 From: James Molson Date: Tue, 25 Feb 2020 14:33:59 +0100 Subject: [PATCH 4/5] Update the changelog. --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 03e34aee5..838cf5ac9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ * Fix pencil beam type 3 - the optics function at the entrance of the collimator were always used for beam sampling, even when those at the exit should have been used (e.g. because the beam is divergent on the cleaning plane). PR #1046 (A. Mereghetti). * Do not update the pair mapping for non-primary particles. PR #1050 (A. Mereghetti) * Removed updating napxo variable in the context of the Fluka-SixTrack coupling. This allows not to screw-up pair mapping in the context of DA studies. PR # 1052 (A. Mereghetti) +* Removed the un-used fluka_init_brhono function (J. Molson). +* When sending particles to geant4, if the particle mass is within a tolerance of the geant4 value, update the mass to this value and re-scale the particle energy (J. Molson). **User Side Changes** From b17b9eb9b94e65af1b370d04ec7e8b41f46f1c07 Mon Sep 17 00:00:00 2001 From: Alessio Mereghetti Date: Wed, 26 Feb 2020 13:40:14 +0100 Subject: [PATCH 5/5] Update CHANGELOG.md --- CHANGELOG.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 838cf5ac9..f21529491 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,9 +8,6 @@ * More robust detection of lxplus at compilation. PR #1045 (J. Molson). * Fix pencil beam type 3 - the optics function at the entrance of the collimator were always used for beam sampling, even when those at the exit should have been used (e.g. because the beam is divergent on the cleaning plane). PR #1046 (A. Mereghetti). * Do not update the pair mapping for non-primary particles. PR #1050 (A. Mereghetti) -* Removed updating napxo variable in the context of the Fluka-SixTrack coupling. This allows not to screw-up pair mapping in the context of DA studies. PR # 1052 (A. Mereghetti) -* Removed the un-used fluka_init_brhono function (J. Molson). -* When sending particles to geant4, if the particle mass is within a tolerance of the geant4 value, update the mass to this value and re-scale the particle energy (J. Molson). **User Side Changes** @@ -27,6 +24,13 @@ * relativistic gamma of lens beam added to calculation of theta_R2; * removed remaining signs of chebyshev polynomials in elens module; Documentation changed accordingly (user and physics manual). +* When sending particles to geant4, if the particle mass is within a tolerance of the geant4 value, update the mass to this value and re-scale the particle energy. PR # 1055 (J. Molson). + +**Code Improvements and Changes** + +* Removed updating napxo variable in the context of the Fluka-SixTrack coupling. This allows not to screw-up pair mapping in the context of DA studies. PR # 1052 (A. Mereghetti) +* Removed the un-used fluka_init_brhono function. PR # 1055 (J. Molson). +* Print error codes from the fluka coupling. PR # 1055 (J. Molson) ### Version 5.4.3 [19.12.2019] - Release