Created magnetic field used mgfield.f routine

Dear FLUKA expert,
I am trying to add a solenoid magnet to my simulation․To approximate the magnetic field of the solenoid, the simulation uses the Biot-Savart law. I did this using a simplified expression.

As a result of FLUKA, we get the following magnetic field.

If we compare the FLUKA results for the magnetic field with the expression, we see that they agree well.
But I can’t understand the results that get from USRBIN [BEAMPART], which you can see below. In the region of the magnetic field, the intensity is incorrect.

Please can you help me understand what I am missing or doing wrong?
Also, you could find input files.

magfld_Solenoid.f (3.1 KB)
solenoid.flair (3.4 KB)
solenoid.inp (1.5 KB)

Thanks in advance for any help!
Best regards
Zohrab

Dear @zamirkhanyan ,

the direction cosines of the magnetic field must be normalised as indicated in the manual.

A modified magnetic field routine is here
magfld_Solenoid.f (3.4 KB)
where I implemented the normalisation.

I didn’t check the correctness of your code, but it is recommend to use everywhere DOUBLE PRECISION variables, i.e. 0.5 should be replaced by 0.5D0

Best, Luigi

1 Like

Dear Luigi,
Thank you VERY much for your help!
Best regards
Zohrab