29 Dec 2008 revisions of MCLIB / MC_Run 1. New function IMPULSE, and new sample type 33, deep-inelastic scattering by impulse approximation. 2. All detector types (40-44) duplicated as Resonance Detectors, types 45-49. Subroutine Operate.f computes efficiencies from nuclear cross sections including Doppler bropadening. 3. Allow source to be extrapolated higher energies than tabulated (type 92). 4. New function erfc.c, error function. 5. Fixed error in Read_2D: when computing linear time scale for second dimension, was putting Tmax in X instead of Y. 08 Nov 2006 revisions of MCLIB / MC_Run 1. Check weight of scattered/split neutron against WT_MIN before banking. 2. WT_FRAC was missing from Namelist input of runtime parameters. 3. Exit multi-region regions before recording in Monitor or Correlation files. 4. Absorption at type 4 surfaces or when following region is absorber is now recorded properly in the following region. 5. Modified DTOEX and DIST to avoid moving to current surface if any other surface has a positive distance, even if less than distance to current surface. 6. Use binomial distribution for error bars of polarization components. 7. Corrected output of polarization in 2D files; fixed memory allocation for polarization components vs. lambda. 8. Changed efficiency of spin flipper to be velocity dependent. 9. Major restructure of NOPTICS, to force spin splitting when reflection causes polarization >0.1%, or to split when reflection is 1-99%. Include type 3 (diffuse) and 4 (absorbing) surfaces. 10. Modified WOBBLE to exclude slopes that are self-shadowing (downslope greater than inclination of trajectory). 11. Batch runs were not reinitializing time and detector bin arrays, and corresponding error message was faulty. 04 Aug 2006 revisions of MCLIB / MC_Run 1. Routines ATTEN_Al and ATTEN_Be have added (optional) parameter in calling sequence to return the fraction of the cross section due to nuclear absorption. 2. Routine OPERATE modified for structural/shielding material types 1-5 to return a multiply-scattered neutron in addition to the transmitted (attenuated) neutron (scattering is isotropic elastic only). 3. MC_Run modified to bank a scattered neutron from material types 1-5, exiting the region. 4. Corrected sign error in LMONOCRM (since 22 Apr 2000) for vertical mosaic when the scattering plane is vertical. 5. Upper limit cell returned by in INTERP4 and INTERP8 changed from N to N-1. 6. Detector efficiency included in output data files, ABSTRACT(27). 7. Fixed error in READ2D, skipping datasets with different numbers of Y channels; need to remember input max number for each. 8. Allow overlapping magnetic regions in BREGION; correct errors in BFIELD, MOVEB, and RKPRECES. 9. Don't write explicit time bins in .dat file if pure log scale. 10. N_SOURCE.f modified to do sum of Maxwellians 11. New routine in MCLIB: RAN8, a REAL*8 random number from two calls to RAN0. 12. New algorithm for PLMXWLN, revised PLNORM: call RAN8 and calculate as R*8 before returning as R*4. 13. Include scattering-length densities of Al and Be explicitly in GET_RHO. 01 Dec 2005 revisions of MCLIB / MC_Run 1. Keep motions inside a monochromator (LMONOCRM) in real*8. 2. Increased number of Surfaces allowed from 255 to 400, detectors from 16 to 20. 3. Revised trace of elements along beam axis to prevent some hangup situations, and to report overlapping region definitions. 4. When a neutron is leaving a region at a type 5 surface, test for a valid region across the surface and possibly reflect before transforming coordinates. 30 Dec 2004 revisions of MCLIB / MC_Run *WARNING* Using revised code with some old tables, OR using previous code with any new tables may give peculiar results in first first and last 0.1% of energy and time distributions. 1. Modify MC_Run for repeating, for Batch jobs with single input file. Make reinitialization entries for BREGION, GRAV_FOC, KERNEL, SNGLXTAL. Initialization modifications in N_SOURCE and PLTIME. 2. Made gravity optional by new run-time parameter in MC_Run. 3. Allow saving of all intermediate dumps by new run-time parameter in MC_Run. 4. Last 0.1% at ends of distributions may be specified as power laws instead of carrying the spline curves to the ends. New table files, modifications to PLSPLINE and RSPLINT. 5. Fixed errors in flag, region, and surface numbers in debug lines in .mc file. 6. Show Emin and Emax for square & triangular distributions; change distributions to wavelength instead of velocity. 7. Modified LORRAND to account for precision when testing for zero solid angle, so single-point direction will work. 11 May 2004 revisions of MCLIB / MC_Run *NOTICE* new MC_Run requires PGplot; in Windows must be compiled as "QuikWin". *NOTICE* beta versions between 18 Jan 2003 and 25 Aug 2003 had an error in penetration depth in a powder sample. *WARNING* New calling sequence for PLQSPHR. *WARNING* New calling sequence for KERNEL. 1. Protection against log of negative in data output. 2. Type 1 materials now transmit, scatter, or absorb (was all transmitted with attenuation). 3. Replace generic intrinsics with kind-specific, for F90 standard (and Absoft). 4. Fixed error and changed algorithm for sample-to-detector distance. 5. Fixed error in array bounds in hard-sphere scatter function; allow upper limit. 6. Added scatter & multiple scatter to nuclear resonances (type 7). 7. Removed upper limit on NSPLIT. 8. Changed treatment of absorption in diffraction samples (type 36), now fractional. 9. Allow absorption in KERNEL, to support user-defined scattering functions. 10. Run-time parameter REUSE=n allows source input file to be reread multiple times. 11. Specifying ISEED=0 will randomize it based on system clock. 12. Neutrons omitted at source reported separately, absorption renormalized to number actually tracked. 13. New type 37, Single Crystal Sample, copied from McStas. 14. Run-time parameter TRACE='Y' generates plot of neutron trajectories 15. New function CAPILLARY to track particles inside a torus with constant cross section, curvature, and critical angle. 16. Revised ATTEN_Al and ATTEN_Be to include temperature dependence. Now have 2 parameters in calling sequence (T optional). 17. Recompiled with larger array limits: max xurfaces 255, max regions 255, max parameters 8000. 18. Revised PLEXP because of an extremely rare occurrence of log(0). 19. Check surfaces in chambers for real surfaces BEFORE applying special cases of reflection or absorption. 20. During the check of elements on-axis, the test neutron could get "trapped" when several surfaces had the same z-intercept. 20 Aug 2002 revisions of MCLIB / MC_Run *NOTICE* an error has been fixed (04 May), which gave critical angles too large by a factor of sqrt(2) in all previous versions. Guide transmissions were thus too large. *NOTICE* an error in Soller collimators (and Benders) was introduced into the beta version of 04 May and fixed on 11 Aug 2002. *NOTICE* revised parameters for Fermi chopper routine. *WARNING* new calling sequences for GET_RHO, GET_SPACE, and SINGLEV. 1. Fix error in NOPTICS which doubled (1 - index of refraction). 2. Provide flag to test regions on both sides of a surface in a surrounding region. 3. Change absolute normalization of "new" moderator files; fix error when only a limited range selected. 4. Fix error in indexing tables for spline time functions. 5. For sources not parallel to the z-axis, modify N_source to normalize the velocity properly. 6. Fix normalization error for narrow energy ranges taken from "new" tables. 7. Show the energy range for which the source brightness is given (new calling sequence for GET_SPACE). 8. New magnetic field type 69, superposition of any number of other field types. 9. Revised Fermi Chopper to account more precisely for attenuation in the body and blade materials. 10. Include polarization of nuclear resonant absorbers and reflecting surfaces. 04 Apr 2002 revisions of MCLIB / MC_Run *NOTICE* Source files including "new" in their names will NOT work with previous versions! MCLIB version used must be 19 July 2001 or later. Files with 2-segment switch functions require 05 Aug 2001 or later. *NOTICE* Implementation of mosaic crystal uses same parameters, but different algorithm *WARNING* WHICHR is now a Logical function with a new(er) calling sequence. 1. Fix splitting of histories on type "6" surfaces. 2. Bender doesn't have to rotate coordinates. 3. New mosaic crystal algorithm including analytic solution of Darwin eqns. 4. New subroutines to support spline tables: PLSPLINE and RSPLINT. 5. Modifications of N_SOURCE and SRC_PROB for source files using spline tables, indicated by table region type 92 instead of 91. 6. Fixed (rare) exponential overflow for some "lost" neutrons. 7. Put # of starts (and weights) in .mon file header. 8. Make multiply-defined source region for .mon file a warning instead of fatal. 9. Fixed error in OPERATE crossing between slits in vertical radial Soller. 10. New routine for magnetic induction field of a SOLENOID; revised algorithm for complete elliptic integrals in CMPLT_PI. 11. Scattering sample subtype 32.6 with elastic multiple scattering into 4pi. 12. Implement "Monitor" detectors with perfect efficiency and no absorption, flag is negative absorption. 13. Provide for polarized source (monochromatic only), and spin flipper. 08 Oct 2000 revisions of MCLIB / MC_Run *WARNING* Calling sequence of OPERATE (and also TYPE_75 - 79) has changed to include flag for magnetic fields. *WARNING* Calling sequence of EXIT_REG has changed to include ELEMENT definitions. *WARNING* Definition and value of magnetic precession constant PRECES_N changed. *WARNING* Calling sequence of GET_RHO changed to include magnetic term. *WARNING* WHICHR is now an integer function with a new calling sequence. 1. Added magnetic field flag in MC_Run and OPERATE. 2. New Magnetic field routines: MOVEB, BFIELD, BINTEGRAL, BREGION, GET_BMAP, BLOOP, SOLENOID 3. New utilities used to compute magnetic fields: RK4BLOCH, RKPRECES, ELLIPTIC, CMPLT_PI 4. New surface flag value +10 or -10 defining magnetic regions not coincident with real surfaces. 5. Materials with subtype .1 are magnetic. 6. Detectors with subtype .4 added record polarization components. 7. Surface interactions removed from MC_Run to new subroutine NOPTICS. Polarization included. 8. Transmitted neutrons now recorded in detectors, unless a Beamstop is used. 9. When recording 3D detector, a 2D sum over time is also stored. 10. Conversion to radial detector bins measured from an axis instead of detector center. 11. Logarithmic lambda bin boundaries are implicit rather than explicit in output files. 12. Protect against argument .le. 0 in GAMMLN. 13. New option in Ikeda-Carpenter form with parameters being simple functions of lambda. 14. Energy spectra lookup tables may use Lorentzian or uniform reference instead of Gaussian. 15. Fixed sign error in final roation in LMONOCRM. 16. Revised treatment of removable beamstop in MC_Run. 17. Fixed error allowing square root of negative when writing output or intermediate dump. 18. Subroutines READ_1D and READ_2D have new block type "IHIST" to compute standard deviation. 19. Magnetic regions excluded when searching for region with WHICHR. 18 Sep 1999 revisions of MCLIB/MC_RUN *WARNING* New algorithm and new calling sequence for mosaic crystals. Old "Monochromator" elements in MC_Web must be deleted and replaced by new "Mosaic" elements. Monochromator types will not work with new versions of MC_RUN, and Mosaic types will not work with old versions of MC_RUN. *WARNING* Type 30 (constant-Q samples), units of transmission parameter changed to agree with other sample types; divide previous parameter 1 by sample thickness (m). *WARNING* Types 11 & 12 (Soller collimators), parameters changed. Old geometry files will not work with new MC_RUN and vice versa. 1. Increased numbers of surfaces, regions, and parameters in mc_geom.inc 2. Fixed error (wavelength) in SRC_PROB 3. Fixed error in encoding vertical cylindrical detector. 4. Improve correlation file for "previous neutron" in a chamber. 5. Fixed error in PLORENTZ when XBAR not zero. 6. Added subtype 32.4 with widths for inelastic levels. 7. Modified WHICHR and SAMESURF for better detection of source region; modified MC_RUN accordingly. 8. Fix error in MC_RUN for 1D plot of XYt detector (was R instead of t); allow center outside of detector area. Also fix multiple 2D plots. 9. Add time (from exponential distribution) for neutron to penetrate detector. 10. New algorithm for mosaic crystals, including absorption and scatter, and reflecting planes non-parallel to surface. Obsolete subroutine MOSAIC removed from MCLIB. 11. Fixed multiple scatter for type 30, allow large-angle scattering. 12. Monoenergetic pulsed source may have pulse width and chopper phase test. 13. New function, PARCYL (parabolic cylinder function of order -1/2). 14. MC_RUN detector output normalized to MW-s. 15. New Soller collimator subtypes, .1 for bender and .2 for radial. Allow offsets, tilt, and slope. Fixed error when leaving through sides of collimator. 16. New material type 7 for nuclear resonances (e.g., Cd, Sm, 240Pu). New function SINGLEV, and modifications to MC_RUN and OPERATE. 12 Mar 1999 revisions of MCLIB/MC_RUN *WARNING* Energy units in geometry files for types 32 (inelastic scatter) and 90 (source) have been changed from eV to meV. Old geometry files will have to be edited to run with the new MC_RUN. In particular, parameters 10 and 11 of type 90 (the lower and upper limits of energy to be sampled) must be multiplied by 1000. *WARNING* Type 90 (source) energy table pointer has been corrected. New version of N_SOURCE requires 1 smaller; that is, if parameter 14 was 20 it must be changed to 19. *WARNING* Include files CONSTANT.INC and MC_GEOM.INC have been changed. The constants and also surfaces and region parameters are now REAL*8 instead of REAL*4, and energy units are consistently meV instead of eV. The entire library should be recompiled with these new include files. *NOTICE* The MC_Web application is now at http://strider.lansce.lanl.gov/NISP/Welcome.html A new version of the MCLIB source code and documentation and a new version of MC_RUN have been placed in the ftp site at ftp://ftp.lanl.gov/public/NISP/ Changes from the previous version (temporarily preserved in directory /version980825/) include 1. All internal computations except random variates and complex numbers are double precision. Most calling sequence arguments are REAL*8, except that since elements of the PARTICLE structure remain REAL*4, routines using them as explicit arguments may expect REAL*4 values. Constants used as input arguments must be explicitly REAL*4 or REAL*8. 2. Several subroutines have been replaced by dual versions, respectively for REAL*4 and REAL*8 arguments. Specifically, DIGITS --> DIGITS4 and DIGITS8 HUNT --> HUNT4 and HUNT8 INTERP --> INTERP4 and INTERP8 NORM --> NORM4 and NORM8 REALOUT --> REAL4OUT and REAL8OUT 3. A new subroutine (SAMESURF) is provided to test if two surfaces are the same within 1 part in 10^8. 4. New parameter in calling sequence for DIST, and revised call in DTOEX, to correct for computed distance to the surface the particle is supposed to be on. The particle may back up to that surface. 5. Time distribution routines (PLTIME and PLIKCARP) now have wavelength instead of energy in the calling sequence. Calls from N_SOURCE modified accordingly. 6. Fixed bug in N_SOURCE that emission time was not correct when projecting back to a tilted source surface. Removed "-1" from energy-table pointer. 7. Output data blocks now have explicit zeros instead of null fields. 8. Calling sequence of WOBBLE changed to omit BETA (available in the PART structure). 9. New region type=15 for multiple identical segments with possible beam-axis rotation in each segment (specifically intended for curved guides). Segments may contain any number of subregions. Subroutine OPERATE and program MC_RUN have been modified in how they handle the exit from complex regions. 10. MC_RUN has been restructured to improve code readability. Two major sections for detector initialization and output have been extracted to subroutines DET_INIT and DET_OUTPUT. Fixed bug in output of XY detector data for steady-state sources. 11. When a 3D histogram is requested, the 2D sum over all time slices is also computed. 12. Fixed bug in N_SOURCE that "bad neutron" flag was not reset if there was no time distribution. 25 Aug 1998 revisions of MCLIB/MC_RUN A new version of the MCLIB source code and documentation and a new version of MC_RUN have been placed in the ftp site at ftp://azoth.lansce.lanl.gov/pub/mclib/ Changes from the previous version (temporarily preserved in directory /version980526/) include 1. NEW LOOK for input of run-time parameters in MC_RUN, using namelist instead of asking questions. See the sample ".in" files in the /Tests folder. 2. Added new region type 21, Fermi chopper. 3. Fixed error in OPERATE for type 32.2, inelastic isotropic scatterer with spectrum of energy levels. Also fixed error in attenuation factor for type 32. 4. Fixed error in DET_2D for negative azimuthal angles always being outside limits. Changed definitions of azimuthal angles for Y- and Z-axes to agree wit MC_Web. 5. Fixed error computing linear time scale in READ_1D. 6. MC_RUN 1-D output spectrum files are for full time bin range, not just between first and last bins with non-zero values. 7. MC_RUN 2-D output files now always have BINS blocks. The 2-character file types are more accurate. ("H" means theta and "F" means phi.) Detector region names are shown in the header line. 8. Modified OPERATE and DET_2D to allow detector linear scales to be inverted; i.e., allow Xmax < Xmin. 9. Omitted some obsolete (undocumented) .TBL files. 10. Neutrons whose statistical weight drops below a minimum are Russian rouletted instead of automatically dying. 11. Provides a Windows application ("See_MC_Data.exe", in the /Analysis folder) for indexing and plotting an output data file. 26 May 1998 revisions of MCLIB/MC_RUN *WARNING* Parameter numbers for small-angle (type 30) and for powder diffraction (type 36) samples, and also a parameter name for reflectometry (type 35) have changed. Any programs which generate geometry files must be recompiled with the new version of 'mc_elmnt.inc'. A new version of the MCLIB source code and documentation and a new version of MC_RUN have been placed in the ftp site at ftp://azoth.lansce.lanl.gov/pub/mclib/ Changes from the previous version (temporarily preserved in directory /version971217/) include 1. In MC_RUN, the source region in a type 95 file may be off-axis. 2. Fixed 2 errors in OPERATE, dealing with reflectometry (type 35) and toroids (type 14). 3. User types 70-79 are linked to OPERATE so that a developer won't have to modify OPERATE when testing a new algorithm. Calling sequences for types 70-74 do not include external geometry, and types 75-79 include all of the instrument geometry definition. 4. Isotropic scatterer has new subtype 32.2 with multiple energy levels. Subtype 32.3 combines this feature with the same limited solid angle as subtype 32.1 5. New library function ELSCAT2 limits the azimuthal angle (around the initial neutron velocity direction) of the scattered neutron to fall within a specified range. 6. Two new parameters, PHI_MIN and PHI_MAX, are included in most sample types (see *WARNING* above). Odd-numbered subtypes of 30, 34, and 36 limit the scattered neutrons to this azimuthal angular range. 7. Parameter name ROUGHNESS was changed to RUF_LAYER in mc_elmnt.inc and in Reflayer.f. 8. There are two new .TBL files: upgd0A10.tbl is the same spectrum as upgd0_10.tbl, with improved time fit upgd2_10.tbl adds a Gd poison to the decoupled moderator of upgrade rev. 0 9. A new subroutine in the Analysis directory, dOmega.f, computes the solid angle described by limits in the ranges of the X-, Y-, and Z-direction cosines (as for type 32.1). 17 December 1997 versions of MCLIB/MC_RUN A new version of the MCLIB source code and documentation and a new version of MC_RUN have been placed in the ftp site at ftp://azoth.lansce.lanl.gov/pub/mclib/ Changes from the previous version (temporarily preserved in directory /version971110/) include 1. Increased dimension of geometry structures: Max surfaces = 152 Max regions = 150 Max parameters = 1620 2. New scattering sample type 32.1, which is an inelastic isotropic scatterer (like 32.0) but with a limited solid angle. 3. Reordering in LMONOCRM (crystal monochromator/analyzer) to make it more likely to get a reflected neutron. 4. New function LORRAND to compute uniform distribution of unit vectors in a specified solid angle. 5. Subroutine N_SOURCE now applies cosine rule to inclined moderator surface, and also computes a time-of-emission for triangular and square velocity distributions. 6. OPERATE updated for type 32.1, and revised flag used to indicate reflection. 7. Function RAN0 has a second argument, which is a flag to save or restore the random-number environment. This required modifications in the following subroutines: N_SOURCE ORRAND PLCNVL PLIKCARP PLNORM PLORENTZ PLPOISSN RNDCRCL 8. MC_RUN will now save a correlation file (.COR) along with the monitor (.MON) file. After you specify a surface to be monitored, you may correlate all neutrons crossing that surfasce with any previous surface, with the source, or with the immediately preceding event before hitting the monitor surface. 9. Neutrons may be flagged as "bad" by various procedures. If a "bad" neutron hits the sample or any detector, its history may be repeated and written to a file (.BAD). 10. Fixed some problems finding source region for type 95, with reflection, and with parameter in output file specifying 2nd dimension. 11. There are 3 "identical" versions of MC_RUN in the directory: MC_RUN.FOR for Fortran90, especially Windows MC_RUN.F for HP-Unix (F77 with VAX extensions) MC_RUN.VAX for VMS Fortran (other than version 6.1)