Exemple #1
0
def dOmega(theta_lab, n):
    """
    function to find dΩlab/dΩcm

    Arguments
    ---------
    theta_lab : scattering angle in the lab system [rad]
    n         : A_t / A_i; A_t, A_i means mass number of target particle or incident particle

    Return
    ------
      dΩlab/dΩcm : factor to convert differential cross-section in the lab system to differential cross-section in the center-of-mass system

    Notice
    ------
    This function do not consider relativity
    """
    if isinstance(theta_lab, uncertainties.core.AffineScalarFunc):
        return umath.pow(
            2.0 * umath.cos(theta_lab) / n +
            (1.0 + umath.cos(2.0 * theta_lab) / (n**2.0)) /
            umath.sqrt(1.0 - umath.pow(umath.sin(theta_lab) / n, 2.0)), -1.0)
    elif isinstance(theta_lab, np.ndarray) and isinstance(
            theta_lab[0], uncertainties.core.AffineScalarFunc):
        return unp.pow(
            2.0 * unp.cos(theta_lab) / n +
            (1.0 + unp.cos(2.0 * theta_lab) /
             (n**2.0)) / unp.sqrt(1.0 - unp.pow(unp.sin(theta_lab) / n, 2.0)),
            -1.0)
    else:
        return np.power(
            2.0 * np.cos(theta_lab) / n +
            (1.0 + np.cos(2.0 * theta_lab) /
             (n**2.0)) / np.sqrt(1.0 - np.power(np.sin(theta_lab) / n, 2.0)),
            -1.0)
Exemple #2
0
def rutherford(theta, T, Zi, Zt, which="inc"):
    """
    Rutherford Scattering in the center-of-mass system

    Arguments
    ---------
    theta : scattering angle in the center-of-mass system
    T     : kinetic energy of incident particle in the center-of-mass system
    Zi    : atomic number of incident particle; charge in units of e
    Zt    : atomic number of target particle; charge in units of e
    which : if which="inc", calc dσ/dΩ(θ) of incident particle.
            if which="tar", calc dσ/dΩ(θ) of target particle.
            if which="sum", calc dσ/dΩ(θ) of incident particle + dσ/dΩ(θ) of target particle.

    Return
    ------
    dσ/dΩ(θ) in the center-of-mass system [mb/str]
    """
    # dσ/dΩ[mb/str]
    # 10.0 : fm^2 --> mb
    if which == "inc":
        # incident particle
        if isinstance(theta, uncertainties.core.AffineScalarFunc):
            return 10.0 * (Zi * Zt * E2 / (4.0 * T))**2.0 * umath.pow(umath.sin(theta / 2.0), -4.0)
        elif isinstance(theta, np.ndarray) and isinstance(theta[0], uncertainties.core.AffineScalarFunc):
            return 10.0 * (Zi * Zt * E2 / (4.0 * T))**2.0 * unp.pow(unp.sin(theta / 2.0), -4.0)
        else:
            return 10.0 * (Zi * Zt * E2 / (4.0 * T))**2.0 * np.power(np.sin(theta / 2.0), -4.0)
    elif which == "tar":
        # target particle
        if isinstance(theta, uncertainties.core.AffineScalarFunc):
            return 10.0 * (Zi * Zt * E2 / (4.0 * T))**2.0 * umath.pow(umath.cos(theta / 2.0), -4.0)
        elif isinstance(theta, np.ndarray) and isinstance(theta[0], uncertainties.core.AffineScalarFunc):
            return 10.0 * (Zi * Zt * E2 / (4.0 * T))**2.0 * unp.pow(unp.cos(theta / 2.0), -4.0)
        else:
            return 10.0 * (Zi * Zt * E2 / (4.0 * T))**2.0 * np.power(np.cos(theta / 2.0), -4.0)
    elif which == "sum":
        # incident particle + target particle
        if isinstance(theta, uncertainties.core.AffineScalarFunc):
            return 10.0 * (Zi * Zt * E2 / (4.0 * T))**2.0 \
                * (umath.pow(umath.sin(theta / 2.0), -4.0) + umath.pow(umath.cos(theta / 2.0), -4.0))
        elif isinstance(theta, np.ndarray) and isinstance(theta[0], uncertainties.core.AffineScalarFunc):
            return 10.0 * (Zi * Zt * E2 / (4.0 * T))**2.0 \
                * (unp.pow(unp.sin(theta / 2.0), -4.0) + unp.power(unp.cos(theta / 2.0), -4.0))
        else:
            return 10.0 * (Zi * Zt * E2 / (4.0 * T))**2.0 \
                * (np.power(np.sin(theta / 2.0), -4.0) + np.power(np.cos(theta / 2.0), -4.0))
    else:
        raise ValueError(
            f"Unrecognized which option:{which}. which must be inc/tar/sum.")
Exemple #3
0
def dOmega(theta_cm, n):
    """
    function to find dΩcm/dΩlab

    Arguments
    ---------
    theta_cm : scattering angle in the center-of-mass system [rad]
    n        : A_t / A_i; A_t, A_i means mass number of target particle or incident particle

    Return
    ------
      dΩcm/dΩlab : factor to convert differential cross-section in the center-of-mass system to one in the lab system

    Notice
    ------
    This function does not consider relativity
    """
    if isinstance(theta_cm, uncertainties.core.AffineScalarFunc):
        return umath.pow(1.0 + 2.0 * umath.cos(theta_cm) / n + 1.0 / n**2.0, 3 / 2) \
            / (1.0 + umath.cos(theta_cm) / n)
    elif isinstance(theta_cm, np.ndarray) and isinstance(
            theta_cm[0], uncertainties.core.AffineScalarFunc):
        return unp.pow(1.0 + 2.0 * unp.cos(theta_cm) / n + 1.0 / n**2.0, 3 / 2) \
            / (1.0 + unp.cos(theta_cm) / n)
    else:
        return np.power(1.0 + 2.0 * np.cos(theta_cm) / n + 1.0 / n**2.0, 3 / 2) \
            / (1.0 + np.cos(theta_cm) / n)
Exemple #4
0
def theta(theta_lab, n):
    """
    function to convert θ in the lab system to θ in the center-of-mass system

    Arguments
    ---------
    theta_lab : scattering angle in the lab system [rad]
    n         : A_t / A_i; A_t, A_i means mass number of target particle or incident particle

    Return
    ------
    theta_cm  : scattering angle in the center-of-mass system [rad]

    Notice
    ------
    This function do not consider relativity
    """
    if isinstance(theta_lab, uncertainties.core.AffineScalarFunc):
        coslab2 = umath.pow(umath.cos(theta_lab), 2.0)
        coscm = (coslab2 - 1.0) / n \
            + umath.sqrt((1.0 - 1.0 / n**2.0) * coslab2 +
                         umath.pow(coslab2 / n, 2.0))
        return np.sign(theta_lab) * umath.acos(coscm)
    elif isinstance(theta_lab, np.ndarray) and isinstance(
            theta_lab[0], uncertainties.core.AffineScalarFunc):
        coslab2 = unp.pow(unp.cos(theta_lab), 2.0)
        coscm = (coslab2 - 1.0) / n \
            + unp.sqrt((1.0 - 1.0 / n**2.0) * coslab2 +
                       unp.pow(coslab2 / n, 2.0))
        return np.sign(theta_lab) * unp.arccos(coscm)
    else:
        coslab2 = np.power(np.cos(theta_lab), 2.0)
        coscm = (coslab2 - 1.0) / n \
            + np.sqrt((1.0 - 1.0 / n**2.0) * coslab2 +
                      np.power(coslab2 / n, 2.0))
        return np.sign(theta_lab) * np.arccos(coscm)
import uncertainties
from uncertainties import ufloat
import math
import numpy
import numpy
import pylab
from scipy.optimize import curve_fit
import math
import scipy.stats
import uncertainties 
from uncertainties import unumpy
#in MHz ed esce in Hz
Rin=ufloat(15.2,0.2)
Cin=ufloat(230,10)
a=ufloat(19.6,0.1)
b=ufloat(94,1)
m=ufloat(17.6,0.3)
logft=(a-b)/m
ft=unumpy.pow(10,logft)*numpy.power(10,6)
print(ft)
# secondo taglio
a1=ufloat(19.6,0.1)
b1=ufloat(-1.4,0.1)
m1=ufloat(-19.6,0.2)
logft1=(a1-b1)/m1
ft1=unumpy.pow(10,logft1)*numpy.power(10,6)
print('ft1= ',ft1)
#attesoprimotaglio
ftatt=1/(pylab.pi*2*Rin*Cin)
print(ftatt)
Exemple #6
0
from uncertainties import ufloat
from uncertainties import unumpy
import numpy

#Inserire a mano i risultati del fit

#IMPORTANTE: Formalismo per trattare variabili con associata una covarianza, non
#ho mai implementato per ora una analoga funzione sui vettori

print("Frequenza di taglio bassa:\n")
#Inserire la matrice di covarianza
matrix = [[0.0, 1.0, 0.0, 0.0], [1.0, 0.01645, 0.0, 0.0],
          [0.0, 0.0, 0.50193422, 2.35784653],
          [0.0, 0.0, 2.35784653, 11.09527365]]
#Definisco le variabili correlate
(a1, b1, a2, b2) = uncertainties.correlated_values(
    (0.0, 19.58726298, 17.71086057, 94.51293025), matrix)
x = (b1 - b2) / (a2 - a1)
print("Frequenza di taglio bassa = ", unumpy.pow(10.0, x))

print("Frequenza di taglio alta:\n")
#Inserire la matrice di covarianza
matrix = [[0.0, 1.0, 0.0, 0.0], [1.0, 0.01645, 0.0, 0.0],
          [0.0, 0.0, 0.24498001, 0.08087699],
          [0.0, 0.0, 0.08087699, 0.03940115]]
#Definisco le variabili correlate
(a1, b1, a2, b2) = uncertainties.correlated_values(
    (0.0, 19.58726298, -19.61622398, -1.45953847), matrix)
x = (b1 - b2) / (a2 - a1)
print("Frequenza di taglio alta = ", unumpy.pow(10.0, x))
Exemple #7
0
def mott(theta, T, Z, A, S):
    """
    Mott Scattering in the center-of-mass system

    Arguments
    ---------
    theta : scattering angle in the center-of-mass system
    T     : kinetic energy of incident particle in the center-of-mass system
    Z     : atomic number; charge in units of e
    A     : mass number
    S     : spin

    Return
    ------
    dσ/dΩ(θ) in the center-of-mass system [mb/str]
    """
    # rest energy
    mc2 = A * AMU
    # total energy of incident/target particle in the center-of-mass system
    Ecm = (T + 2.0 * mc2) / 2.0
    # gamma (= gamma_cm in this situattion)
    gamma = Ecm / mc2
    # beta (= beta_cm in this situattion)
    beta = np.sqrt(1.0 - 1.0 / gamma**2.0)
    # relative beta in the center-of-mass system
    brel = 2.0 * beta / (1.0 + beta**2.0)

    # dσ/dΩ[mb/str]
    # 10.0 : fm^2 --> mb
    if isinstance(theta, uncertainties.core.AffineScalarFunc):
        return 10.0 * (Z**2 * E2 / (4.0 * T))**2.0 * (
            umath.pow(umath.sin(theta / 2.0), -4.0)
            + umath.pow(umath.cos(theta / 2.0), -4.0)
            + (-1.0)**(2.0 * S) * 2.0 / (2.0 * S + 1.0) *
            umath.pow(umath.sin(theta / 2.0), -2.0) *
            umath.pow(umath.cos(theta / 2.0), -2.0) *
            umath.cos(Z**2.0 * E2 / (HBARC * brel) *
                      umath.log(umath.pow(umath.tan(theta / 2.0), 2.0))
                      )
        )
    elif isinstance(theta, np.ndarray) and isinstance(theta[0], uncertainties.core.AffineScalarFunc):
        return 10.0 * (Z**2 * E2 / (4.0 * T))**2.0 * (
            unp.pow(unp.sin(theta / 2.0), -4.0)
            + unp.pow(unp.cos(theta / 2.0), -4.0)
            + (-1.0)**(2.0 * S) * 2.0 / (2.0 * S + 1.0) *
            unp.pow(unp.sin(theta / 2.0), -2.0) *
            unp.pow(unp.cos(theta / 2.0), -2.0) *
            unp.cos(Z**2.0 * E2 / (HBARC * brel) *
                    unp.log(unp.pow(unp.tan(theta / 2.0), 2.0))
                    )
        )
    else:
        return 10.0 * (Z**2 * E2 / (4.0 * T))**2.0 * (
            np.power(np.sin(theta / 2.0), -4.0)
            + np.power(np.cos(theta / 2.0), -4.0)
            + (-1.0)**(2.0 * S) * 2.0 / (2.0 * S + 1.0) *
            np.power(np.sin(theta / 2.0), -2.0) *
            np.power(np.cos(theta / 2.0), -2.0) *
            np.cos(Z**2.0 * E2 / (HBARC * brel) *
                   np.log(np.power(np.tan(theta / 2.0), 2.0))
                   )
        )
Exemple #8
0
def Eps(ntu,mu):
    """
    cele doua fluide sunt neamestecate
    """
    return 1.-unp.exp(1/mu*unp.pow(ntu,0.22)*(unp.exp(-mu*unp.pow(ntu,0.78))-1))