Version nSpinSim4.0 See Readme.txt in attached .zip file for history of changes. Highlights of changes since nSpinSim3.3, the last posted to the Elog. 1. Additional Aluminum windows with correct thicknesses and locations in beam. 2. Rotation angle is calculated using theta = ArcSin[ Sum[ PA_i*sin(theta_i)]/PA_avg]. PA-value can be set to NSRII specifications or to 1 using PAflg in const.inc. Previously a random number and the PA-value were used to eliminate neutrons, but this affected the detector flux. Now, PA affects only the rotation angle, not the flux as well. 3. Additional Sqrt and trig functions included to prevent infinities and notify the user. Neutron wavelength limited to <20Ang to help eliminate infinites (e.g., energy loss causing a negative energy). 4. New subroutines "beampipe" and "scatb." These are modeled after "empty" and "scate," respectively, to correct the position calculations for neutrons that bounce in the input guide, input coil, and output coil. It also allows neutrons to scatter off of gases in the beamline itself. The beam can be filled with helium gas or air using the flag "hebeam" in const.inc. This more generic beampipe subroutine includes a septum, which can be turned on and off u sing sptmflg in const.inc. 5. The code now can read psm.hbook (histogram 200) which is a beam image showing beam intensity versus x- and y-positions. The histograms 2220,2221,2222,3333,4444 are xy-flux plots at different locations along the beamline, where they give flux values normalized to the calibrated Fission Chamber PSM output measurement during NSRII. Histograms 441--446 are 1-cm wide by 0.02-cm wide slices through the xy-flux plots versus either x or y which give the average flux in that 1-cm by 0.02-cm slice.