Commit cda49eba authored by Zolnierczuk, Piotr's avatar Zolnierczuk, Piotr
Browse files

moved constants to a separate package

parent 158e08d2
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -7,11 +7,12 @@ from numpy import asarray, pi, sin, radians
from matplotlib.patches import Circle, Wedge, Polygon
from scipy.constants import physical_constants, milli, nano

from pysen import KAPPA_N_NSA as KAPPA
from pysen import get_q, get_tau
from pysen.config import PHI_LIMS, J_LIMS

HBAR  = physical_constants['reduced Planck constant in eV s'][0]/milli/nano


def heisenberg(x):
    with np.errstate(divide='ignore'):
        return HBAR/x
@@ -29,9 +30,9 @@ qe_plot = True
fig, ax1 = plt.subplots()

for lam in wlen:
    t = KAPPA*J*lam**3
    t = get_tau(J,lam)
    e = heisenberg(t)
    q = 4*pi/lam*sin(radians(theta/2))
    q = get_q(lam, radians(theta))
    # one
    if lam==wlen[0]:
        _e = e[0],e[0],e[1]
+5 −30
Original line number Diff line number Diff line
"""
Main PySEN package
"""
from math import pi as PI

import scipy.constants as sc

from .physics  import get_theta, get_q, q_binning, l_binning, t_binning # NOQA
from .misc     import setup_logger, dictionary_hash, DEFAULT_LOG_LEVEL  # NOQA
from .revision  import version                                             # NOQA

# h(Planck)/m_n(neutron mass)
HMN     = sc.Planck/sc.neutron_mass #3.95603401e-07 # m*m/s
# neutron gyromagnetic ratio
GAMMA_N = sc.physical_constants['neutron gyromag. ratio'][0] # 183,247,171 s^-1 T^-1

# MU_0 - vacuum magnetic permeability
MU_0 = 4e-7*PI

# Convenience constants
ANGSTROM   = 1e-10 # Angstrom in meters
GAUSS      = 1e-04 # Gauss-> Tesla
#
MICRO      = 1e-06 # mu - micro prefix
NANOSECOND = 1e-09 #

# conversion constant from field integral to phase angle
# phi = OMEGA_N * J * lambda
OMEGA_N = GAMMA_N/HMN

# conversion constant from wavelength and field integral to Fourier time
# tau = KAPPA_N * J * lambda^3
KAPPA_N     = GAMMA_N/(2*PI) * HMN**-2
KAPPA_N_NSA = KAPPA_N * ANGSTROM**3/NANOSECOND  # tau [ns] = KAPPA_N_NSA * J[Tm] l[A]^3
from .constants import *
from .physics   import (get_theta, get_q, q_binning, l_binning, t_binning, # NOQA
                        get_tau)                                           # NOQA
from .misc      import setup_logger, dictionary_hash, DEFAULT_LOG_LEVEL    # NOQA
+2 −2
Original line number Diff line number Diff line
@@ -12,8 +12,8 @@ from numpy import (sqrt, log, log10, sin, cos, arccos, arctan2,
                     radians, degrees, linspace, logspace, isnan)
import numpy  as np

from . import ( get_theta, get_q, q_binning, l_binning,
                KAPPA_N_NSA, HMN, ANGSTROM )
from .constants import KAPPA_N_NSA, HMN, ANGSTROM
from .physics   import get_theta, get_q, q_binning, l_binning

INST_POSITIONS =  ['p1', 'p2', 'p3', 'p4']
INST_MODES     =  ['standard', 'shorty', 'shorty_2', 'mixed']

pysen/constants.py

0 → 100755
+32 −0
Original line number Diff line number Diff line
"""
all the constants go here .....
"""
import scipy.constants as _const

PI = _const.pi

# h(Planck)/m_n(neutron mass)
HMN      = _const.Planck/_const.neutron_mass #3.95603401e-07 # m*m/s
# h(bar) in eV*s
HBAR_EVS = _const.physical_constants['reduced Planck constant in eV s'][0]
# neutron gyromagnetic ratio
GAMMA_N  = _const.physical_constants['neutron gyromag. ratio'][0]# 183,247,171 s^-1 T^-1

# vacuum magnetic permeability
MU_0 = _const.mu_0

# convenience constants
ANGSTROM   = _const.angstrom # Angstrom in meters
GAUSS      = 1e-04 # Gauss-> Tesla
#
MICRO      = _const.micro # mu - micro prefix
NANOSECOND = _const.nano  #

# conversion constant from field integral to phase angle
# phi = OMEGA_N * J * lambda
OMEGA_N = GAMMA_N/HMN

# conversion constant from wavelength and field integral to Fourier time
# tau = KAPPA_N * J * lambda^3
KAPPA_N     = GAMMA_N/(2*PI) * HMN**-2
KAPPA_N_NSA = KAPPA_N * ANGSTROM**3/NANOSECOND  # tau [ns] = KAPPA_N_NSA * J[Tm] l[A]^3
+1 −1
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ from numpy import sum as npsum
from numpy import (outer, sqrt, pi, exp, log, sinc, cos, sign)
from scipy.optimize import minimize_scalar

from .. import OMEGA_N
from ..constants import OMEGA_N

SIGMA2FWHM = 2.0*sqrt(2.0*log(2.0))

Loading