def calculateTimeSteppingCoeffs(self, s):

        Inv_c = s["cosmogenic inventory"]

        # initialize (first time step) or read in coefficients
        if s["age"] == self.timestep:

            s["psi_spallation_coeff"] = 0.0
            s["slowMuonContrib"]      = 0.0
            s["fastMuonContrib"]      = 0.0

            # Initial RHS_1 == Inv_c (or Inv_m - Inv_r)
            s["RHS_1"] = Inv_c

        # Set the decay time for the current nuclide
        self.LAMBDA_36 = Nuclide.decay[self.experiment['nuclide']]

        exp1 = math.exp(-(self.LAMBDA_36) * s["age"])
        #Stable isotopes have no exponential decreasing effect
        if Nuclide.stable(self.experiment['nuclide']):
            exp1 = 1.0
       
        mul0 = -1.0 * self.LAMBDA_36 * self.timestep
        min0 = 1.0 - math.exp(mul0)

        #Stable isotopes have no exponential decreasing effect
        if Nuclide.stable(self.experiment['nuclide']):
           div1 = self.timestep
           mul1 = self.S_el * self.timestep * exp1
        else:
           div1 = min0 / self.LAMBDA_36 
           mul1 = self.S_el * div1 * exp1
        mul2 = self.shielding_factor * self.Q_s 

        s["psi_spallation_coeff"] += mul1 * mul2
        s["slowMuonContrib"] += self.S_mu * div1 * exp1 * self.Q_mu * self.Pmu_slow * self.shielding_factor
        s["fastMuonContrib"] += self.S_mu * div1 * exp1 * self.Q_mu * self.Pmu_fast * self.shielding_factor
        
        # Calculate RHS below.  Note that this is really
        # RHS = InvC - muonContrib
        # As it appears in the time averaing procedure (OutputFor36clCalibration)
        # but from time step to time step it takes away the individual contribution from
        # that time step
        # print s["RHS_1"]
        # print self.Pmu_0
        s["RHS_1"] -= self.S_mu * div1 * exp1 * self.Q_mu * self.Pmu_slow * self.shielding_factor
        s["RHS_1"] -= self.S_mu_fast * div1 * exp1 * self.Q_mu * self.Pmu_fast * self.shielding_factor
    def calculate_age(self, s):

        #print
        #print "Entering calculate_age"
        #print "    age      : " + str(s["age"])
        #print "    Inv_c_mod: " + str(s["Inv_c_mod"])
        #print
        
        # calculate how much the inventory has changed over the timestep
        # also wind the age back timestep years (10)
        
        # Set the decay time for the current nuclide
        self.LAMBDA_36 = Nuclide.decay[self.experiment['nuclide']]
       
        prod0 = -1.0 * self.LAMBDA_36 * self.timestep
        minu0 = 1.0 - math.exp(prod0)
        #Stable isotopes have no exponential decreasing effect
        if Nuclide.stable(self.experiment['nuclide']):
            divi1 = self.timestep
        else:
            divi1 = minu0 / self.LAMBDA_36
        prod1 = s["P_total"] * divi1 
        #prod1 = s["P_total"] * self.timestep
        prod2 = -1.0 * self.LAMBDA_36 * s["age"]
        prod3 = math.exp(prod2)
        prod4 = prod3 * prod1

        #Stable isotopes have no exponential decreasing effect
        if Nuclide.stable(self.experiment['nuclide']):
            prod4 = prod1

        s["Inv_c_mod"] -= prod4
        
        prod5 = s["P_total_uncertainty"] * self.timestep
        prod6 = prod3 * prod5

        #Stable isotopes have no exponential decreasing effect
        if Nuclide.stable(self.experiment['nuclide']):
            prod6 = prod5

        s["Inv_c_uncertainty"] += prod6
Ejemplo n.º 3
0
    def calculatePinv(self, s):
        self.LAMBDA_36 = Nuclide.decay[self.experiment["nuclide"]]
        # calculate time invariant production rate

        prod0 = -1.0 * self.LAMBDA_36 * s["age"]
        denom = 1.0 - math.exp(prod0)
        num = s["cosmogenic inventory"] * self.LAMBDA_36
        # Stable isotopes have no exponential decreasing effect
        if Nuclide.stable(self.experiment["nuclide"]):
            num = s["cosmogenic inventory"]
            denom = s["age"]
        s["production rate invariant"] = num / denom
Ejemplo n.º 4
0
 def UpdateParams(self):
     self.paramsPanel.DestroyChildren()
     self.paramsPanel.SetSizer(None)
     
     for name in ["psi_mu_0", "phi_mu_f0", "slowMuonPerc", "fastMuonPerc"]:
         try:
             self.paramsPanel.Unbind(wx.EVT_TEXT, self.fields[name])
         except:
             pass
         try:
             del self.fields[name]
             del self.values[name]
         except:
             pass
             
     if self.selectedNuclide is not None:
         if self.selectedNuclide == "36Cl":
             self.fields["psi_mu_0"] = wx.TextCtrl(self.paramsPanel, wx.ID_ANY, name="psi_mu_0")
             self.fields["psi_mu_0"].SetValue(str(Nuclide.getSlowMuonStoppingRate()))
             self.error_labels["psi_mu_0"] = wx.StaticText(self.paramsPanel, wx.ID_ANY, '                         ')                
             self.values["psi_mu_0"] = Nuclide.getSlowMuonStoppingRate()
             self.paramsPanel.Bind(wx.EVT_TEXT, self.OnParamUpdate, self.fields['psi_mu_0'])                
             
             self.fields["phi_mu_f0"] = wx.TextCtrl(self.paramsPanel, wx.ID_ANY, name="phi_mu_f0")
             self.fields["phi_mu_f0"].SetValue(str(Nuclide.getFastMuonFlux()))
             self.values["phi_mu_f0"] = Nuclide.getFastMuonFlux()
             self.error_labels["phi_mu_f0"] = wx.StaticText(self.paramsPanel, wx.ID_ANY, '                         ')
             self.paramsPanel.Bind(wx.EVT_TEXT, self.OnParamUpdate, self.fields['phi_mu_f0'])
             
         else:
             self.fields["slowMuonPerc"] = wx.TextCtrl(self.paramsPanel, wx.ID_ANY, name="slowMuonPerc")
             self.fields["slowMuonPerc"].SetValue(str(Nuclide.getSlowMuonPerc(self.selectedNuclide)))
             self.values["slowMuonPerc"] = Nuclide.getSlowMuonPerc(self.selectedNuclide)
             self.error_labels["slowMuonPerc"] = wx.StaticText(self.paramsPanel, wx.ID_ANY, '                         ')
             self.paramsPanel.Bind(wx.EVT_TEXT, self.OnParamUpdate, self.fields['slowMuonPerc'])
             
             self.fields["fastMuonPerc"] = wx.TextCtrl(self.paramsPanel, wx.ID_ANY, name="fastMuonPerc")
             self.fields["fastMuonPerc"].SetValue(str(Nuclide.getFastMuonPerc(self.selectedNuclide)))
             self.values["fastMuonPerc"] = Nuclide.getFastMuonPerc(self.selectedNuclide)
             self.error_labels["fastMuonPerc"] = wx.StaticText(self.paramsPanel, wx.ID_ANY, '                         ')
             self.paramsPanel.Bind(wx.EVT_TEXT, self.OnParamUpdate, self.fields['fastMuonPerc'])
             
         labels = []
 
         if self.selectedNuclide == "36Cl":
             labels.append(wx.StaticText(self.paramsPanel, wx.ID_ANY, "Slow Muon Stopping Rate:"))
             labels.append(wx.StaticText(self.paramsPanel, wx.ID_ANY, "Fast Muon Flux:"))
         else:
             labels.append(wx.StaticText(self.paramsPanel, wx.ID_ANY, "Slow Muon Production:"))
             labels.append(wx.StaticText(self.paramsPanel, wx.ID_ANY, "Fast Muon Production:"))
         
         sizer = wx.GridBagSizer(10, 10)
 
         row = 0
         for label in labels:
             sizer.Add(label, pos=(row, 0), border=5, flag=wx.ALIGN_RIGHT|wx.ALL)
             row += 1
 
         names = []
         if self.selectedNuclide == "36Cl":
             names = ["psi_mu_0", "phi_mu_f0"]
         else:
             names = ["slowMuonPerc", "fastMuonPerc"]
 
         row = 0
         for name in names:
             sizer.Add(self.fields[name], pos=(row, 1), border=5, flag=wx.ALIGN_LEFT|wx.ALL|wx.EXPAND)
             sizer.Add(self.error_labels[name], pos=(row, 2), border=5, flag=wx.ALIGN_LEFT|wx.ALL)
             row += 1
 
         self.paramsPanel.SetSizer(sizer)
         self.paramsPanel.Layout()
         self.ConfigureGrid()
         self.CheckStatus()
     else:
         sizer = wx.BoxSizer(wx.HORIZONTAL)
         sizer.Add(wx.StaticText(self.paramsPanel, wx.ID_ANY, "You need to select a Nuclide\nbefore you can configure an Experiment's Parameters"), border=5, flag=wx.ALL|wx.ALIGN_TOP)
         self.paramsPanel.SetSizer(sizer)
         self.paramsPanel.Layout()