s_guess = 0.6

# stopping power model and parameters
stoppingMedia_Z = 1
stoppingMedia_A = 2
stoppingMedia_rho = 8.565e-5  # from red notebook, p 157
incidentIon_charge = 1
# IMPORTANT
# CHECK TO SEE IF THIS FACTOR OF 1e-3 IS NEEDED
stoppingMedia_meanExcitation = 19.2 * 1e-3  # FACTOR OF 1e-3 NEEDED?
# IMPORTANT
stoppingModelParams = [
    stoppingMedia_Z, stoppingMedia_A, stoppingMedia_rho, incidentIon_charge,
    stoppingMedia_meanExcitation
]
stoppingModel = ionStopping.simpleBethe(stoppingModelParams)

# hack shit
# just because i don't want to change code i copied and pasted below
params = [beamE_guess, eLoss_guess, scale_guess, s_guess, 1e4, 10]
beamE, eLoss, scale, s, scaleFactor, bgLevel = params
ddnXSfxn = ddnXSinstance
dedxfxn = stoppingModel.dEdx

eN_binCenters = getDDneutronEnergy(eD_binCenters)

dedxForODE = lambda x, y: dedxfxn(energy=y, x=x)

nSamples = 10000
nEvPerLoop = 1000
Exemple #2
0
# stopping power model and parameters
stoppingMedia_Z = 1
stoppingMedia_A = 2
stoppingMedia_rho = 8.565e-5  # from red notebook, p 157
incidentIon_charge = 1
stoppingMedia_meanExcitation = 19.2 * 1e-3
dgas_materialDef = [
    stoppingMedia_Z, stoppingMedia_A, stoppingMedia_rho,
    stoppingMedia_meanExcitation
]
stoppingModelParams = [
    stoppingMedia_Z, stoppingMedia_A, stoppingMedia_rho, incidentIon_charge,
    stoppingMedia_meanExcitation
]
#stoppingModel = ionStopping.simpleBethe( stoppingModelParams )
stoppingModel = ionStopping.simpleBethe([1])
stoppingModel.addMaterial(dgas_materialDef)

eN_binCenters = getDDneutronEnergy(eD_binCenters)


def getTOF(mass, energy, distance):
    """
    Compute time of flight, in nanoseconds, given\
    mass of particle (in keV/c^2), the particle's energy (in keV),\
    and the distance traveled (in cm).
    Though simple enough to write inline, this will be used often.
    """

    velocity = physics.speedOfLight * np.sqrt(2 * energy / mass)
Exemple #3
0
    ionCharge = 1 # little z in equation, in multiples of elementary charge
    leadingTerm = (4 * np.pi * numDensity * ionCharge**2 /
                   (masses.electron * physics.speedOfLight**2 * velocity**2))
    #squareTerm = (sciConsts.e**2/(4 * np.pi * physics.epsilon_0))**2
    squareTerm = 1.67489e-14 # worked out on paper
    iExcitationPot = 19.2 # from http://pdg.lbl.gov/2016/AtomicNuclearProperties/HTML/deuterium_gas.html
    logArg = (2 * masses.electron /(physics.speedOfLight**2)* velocity**2 /
              (iExcitationPot*1e-3))
    stopping = -1 * leadingTerm * squareTerm * np.log(logArg)
#    print('leading term {}\nmiddle term {}\nlog term {}'.format(np.log10(leadingTerm),
#                                                                squareTerm,
#                                                                np.log(logArg)))
    return stopping


stoppingModel = ionStopping.simpleBethe([1, 2, 8.37e-5, 1, 19.2])

energies = np.linspace(900, 1100, 3)
#stoppingPowers = stoppingFxn(energies)
print('D energy\tstopping from fxn\tstopping from class')
for idx, energy in enumerate(energies):
    print('{}\t{}\t{}'.format(energy,stoppingFxn(energy),stoppingModel.dEdx(energy)))


eZeros = np.random.normal(900.0, 50, 5000)

xLocations = np.linspace(0.0, distances.tunlSSA_CsI.cellLength, 50)
solutions = odeint( stoppingModel.dEdx, eZeros, xLocations)


for idx in range(0,solutions.shape[1]):
Exemple #4
0
    def __init__(self,
                 chainFilename,
                 nSamplesFromTOF,
                 nBins_eD=100,
                 nBins_x=20,
                 nRuns=4):
        """Create a PPC tools object - reads in chain from file"""
        self.chain, self.probs, self.nParams, self.nWalkers, self.nSteps = readChainFromFile(
            chainFilename)

        self.nRuns = nRuns

        self.eD_bins = nBins_eD
        self.eD_minRange = 200.0
        self.eD_maxRange = 1200.0
        self.eD_range = (self.eD_minRange, self.eD_maxRange)
        self.eD_binSize = (self.eD_maxRange - self.eD_minRange) / self.eD_bins
        self.eD_binCenters = np.linspace(
            self.eD_minRange + self.eD_binSize / 2,
            self.eD_maxRange - self.eD_binSize / 2, self.eD_bins)
        self.eD_binMax = self.eD_bins - 1

        self.x_bins = nBins_x
        self.x_minRange = 0.0
        self.x_maxRange = distances.tunlSSA_CsI.cellLength
        self.x_range = (self.x_minRange, self.x_maxRange)
        self.x_binSize = (self.x_maxRange - self.x_minRange) / self.x_bins
        self.x_binCenters = np.linspace(self.x_minRange + self.x_binSize / 2,
                                        self.x_maxRange - self.x_binSize / 2,
                                        self.x_bins)

        # parameters for making the fake data...
        self.nEvPerLoop = nSamplesFromTOF
        self.nSamplesFromTOF = nSamplesFromTOF
        self.data_x = np.repeat(self.x_binCenters, self.nEvPerLoop)

        self.ddnXSinstance = ddnXSinterpolator()
        self.beamTiming = beamTimingShape()
        self.zeroDegTimeSpreader = zeroDegreeTimingSpread()

        # stopping power model and parameters
        stoppingMedia_Z = 1
        stoppingMedia_A = 2
        stoppingMedia_rho = 8.565e-5  # from red notebook, p 157
        incidentIon_charge = 1
        stoppingMedia_meanExcitation = 19.2 * 1e-3
        dgas_materialDef = [
            stoppingMedia_Z, stoppingMedia_A, stoppingMedia_rho,
            stoppingMedia_meanExcitation
        ]
        #stoppingModel = ionStopping.simpleBethe( stoppingModelParams )
        self.stoppingModel = ionStopping.simpleBethe([incidentIon_charge])
        self.stoppingModel.addMaterial(dgas_materialDef)

        self.eN_binCenters = getDDneutronEnergy(self.eD_binCenters)

        tofWindowSettings = tofWindows()
        tof_nBins = tofWindowSettings.nBins
        self.tof_minRange = [
            tofWindowSettings.minRange['mid'],
            tofWindowSettings.minRange['close'],
            tofWindowSettings.minRange['close'],
            tofWindowSettings.minRange['far'],
            tofWindowSettings.minRange['production']
        ]
        self.tof_maxRange = [
            tofWindowSettings.maxRange['mid'],
            tofWindowSettings.maxRange['close'],
            tofWindowSettings.maxRange['close'],
            tofWindowSettings.maxRange['far'],
            tofWindowSettings.maxRange['production']
        ]
        self.tof_range = []
        for minR, maxR in zip(self.tof_minRange, self.tof_maxRange):
            self.tof_range.append((minR, maxR))
        self.tofRunBins = [
            tof_nBins['mid'], tof_nBins['close'], tof_nBins['close'],
            tof_nBins['far'], tof_nBins['production']
        ]

        self.standoffs = [
            distances.tunlSSA_CsI.standoffMid,
            distances.tunlSSA_CsI.standoffClose,
            distances.tunlSSA_CsI.standoffClose,
            distances.tunlSSA_CsI.standoffFar,
            distances.tunlSSA_CsI.standoff_TUNLruns
        ]

        self.tofData = None
        self.neutronSpectra = None

        self.paramNames = [
            '$E_0$', '$f_1$', '$f_2$', '$f_3$', '$N_1$', '$N_2$', '$N_3$',
            '$N_4$', '$N_5$'
        ]