Calculates quasiparticle weight
17374
def quasiparticle_weight(self):
        """"""
        return np.array([self.expected(op)**2 for op in self.oper['O']])
1270774
def perform_es_corr(self, lattice, q, step=1e-4):
        
        logger.info("Running Freysoldt 2011 PC calculation (should be " "equivalent to sxdefectalign)")
        logger.debug("defect lattice constants are (in angstroms)" + str(lattice.abc))

        [a1, a2, a3] = ang_to_bohr * np.array(lattice.get_cartesian_coords(1))
        logging.debug("In atomic units, lat consts are (in bohr):" + str([a1, a2, a3]))
        vol = np.dot(a1, np.cross(a2, a3))  # vol in bohr^3

        def e_iso(encut):
            gcut = eV_to_k(encut)  # gcut is in units of 1/A
            return scipy.integrate.quad(lambda g: self.q_model.rho_rec(g * g)**2, step, gcut)[0] * (q**2) / np.pi

        def e_per(encut):
            eper = 0
            for g2 in generate_reciprocal_vectors_squared(a1, a2, a3, encut):
                eper += (self.q_model.rho_rec(g2)**2) / g2
            eper *= (q**2) * 2 * round(np.pi, 6) / vol
            eper += (q**2) * 4 * round(np.pi, 6) \
                * self.q_model.rho_rec_limit0 / vol
            return eper

        eiso = converge(e_iso, 5, self.madetol, self.energy_cutoff)
        logger.debug("Eisolated : %f", round(eiso, 5))

        eper = converge(e_per, 5, self.madetol, self.energy_cutoff)

        logger.info("Eperiodic : %f hartree", round(eper, 5))
        logger.info("difference (periodic-iso) is %f hartree", round(eper - eiso, 6))
        logger.info("difference in (eV) is %f", round((eper - eiso) * hart_to_ev, 4))

        es_corr = round((eiso - eper) / self.dielectric * hart_to_ev, 6)
        logger.info("Defect Correction without alignment %f (eV): ", es_corr)
        return es_corr
160961
@Override
    public DescriptorValue calculate(IAtomContainer atomContainer) {

        int n = 0; // count all heavy atom - heavy atom bonds
        for (IBond bond : atomContainer.bonds()) {
            if (bond.getBegin().getAtomicNumber() != 1 && bond.getEnd().getAtomicNumber() != 1) {
                n++;
            }
        }

        double vadjMa = 0;
        if (n > 0) {
            vadjMa += (Math.log(n) / Math.log(2)) + 1;
        }
        return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), new DoubleResult(vadjMa),
                getDescriptorNames());
    }
711476
def bethe_fermi(energy, quasipart, shift, hopping, beta):
    """"""
    return fermi_dist(quasipart * energy - shift, beta) \
            * bethe_lattice(energy, hopping)
801965
def seebeck_eff_mass_from_seebeck_carr(seeb, n, T, Lambda):
    
    try:
        from fdint import fdk
    except ImportError:
        raise BoltztrapError("fdint module not found. Please, install it.\n"+
                            "It is needed to calculate Fermi integral quickly.")

    eta = eta_from_seebeck(seeb,Lambda)
    mass = seebeck_eff_mass_from_carr(eta, n, T, Lambda)
    return mass
763259
def cal_pst(self, v):
        
        p_h = self._hugoniot_p(v)
        p_th_h = self._hugoniot_pth(v)
        p_st = p_h - p_th_h
        return p_st
905764
def molecular_weight(elements):
    
    return (np.array([atomic_mass[i.upper()] for i in elements]).sum())
1099278
def solve_loop(slsp, u_span, j_coup):
    """"""

    zet, lam, eps, hlog, mean_f = [], [], [], [], [None]

    for u in u_span:
        print(u, j_coup)
        hlog.append(slsp.selfconsistency(u, j_coup, mean_f[-1]))
        mean_f.append(slsp.mean_field())
        zet.append(slsp.quasiparticle_weight())
        lam.append(slsp.param['lambda'])
        eps.append(orbital_energies(slsp.param, zet[-1]))

    return np.asarray([zet, lam, eps]), hlog, mean_f
676261
def inter_spin_hamiltonian(self, u_int, J_coup):
        """"""
        J_coup *= u_int
        h_int  = (u_int - 2*J_coup)/2.*self.oper['sumSz2']
        h_int += J_coup*self.oper['sumSz-sp2']
        h_int -= J_coup/2.*self.oper['sumSz-or2']
        h_int -= J_coup*self.oper['Sfliphop']

        return h_int
659109
def est_entropy(self):
        
        """
        nz_weights = self.particle_weights[self.particle_weights > 0]
        return -np.sum(np.log(nz_weights) * nz_weights)
120313
def bethe_filling_zeroT(fermi_energy, hopping):
    """"""
    fermi_energy = np.asarray(fermi_energy).clip(-2*hopping, 2*hopping)
    return 1/2. + fermi_energy/2 * bethe_lattice(fermi_energy, hopping) \
                    + np.arcsin(fermi_energy/2/hopping)/np.pi
390870
def fermion_avg(efermi, norm_hopping, func):
    """"""
    if func == 'ekin':
        func = bethe_ekin_zeroT
    elif func == 'ocupation':
        func = bethe_filling_zeroT

    return np.asarray([func(ef, tz) for ef, tz in zip(efermi, norm_hopping)])
141149
def _compute_weights(self):
        

        n = self.n
        k = self.kappa

        self.Wm = np.full(2*n+1, .5 / (n + k))
        self.Wm[0] = k / (n+k)
        self.Wc = self.Wm
615585
def determine_coefficient
      # Array of photon energies (in units of MeV).
      @energies = [
        0.001,
        0.0015,
        0.002,
        0.003,
        0.004,
        0.005,
        0.006,
        0.008,
        0.01,
        0.015,
        0.02,
        0.03,
        0.04,
        0.05,
        0.06,
        0.08,
        0.1,
        0.15,
        0.2,
        0.3,
        0.4,
        0.5,
        0.6,
        0.8,
        1.0,
        1.25,
        1.5,
        2.0,
        3.0,
        4.0,
        5.0,
        6.0,
        8.0,
        10.0,
        15.0,
        20.0
      ]
      # Array of mass attenuation coefficients for the above energies, for liquid water (in units of cm^2/g):
      @att_coeffs = [
        4078,
        1376,
        617.3,
        192.9,
        82.78,
        42.58,
        24.64,
        10.37,
        5.329,
        1.673,
        0.8096,
        0.3756,
        0.2683,
        0.2269,
        0.2059,
        0.1837,
        0.1707,
        0.1505,
        0.137,
        0.1186,
        0.1061,
        0.09687,
        0.08956,
        0.07865,
        0.07072,
        0.06323,
        0.05754,
        0.04942,
        0.03969,
        0.03403,
        0.03031,
        0.0277,
        0.02429,
        0.02219,
        0.01941,
        0.01813
      ]
      # Determine the coefficient:
      if @energy >= 20.0
        # When the energy is above 20, we use the coefficient for 20 MeV:
        @ac_water = @att_coeffs.last
      else
        if i = @energies.index(@energy)
          # When it exactly matches one of the listed energies, use its corresponding coefficient:
          @ac_water = @att_coeffs[i]
        else
          # When the given energy is between two of the listed values, interpolate:
          i_after = @energies.index {|x| x > @energy}
          if i_after
            e_high = @energies[i_after]
            e_low = @energies[i_after - 1]
            ac_high = @att_coeffs[i_after]
            ac_low = @att_coeffs[i_after - 1]
            @ac_water = (ac_high - ac_low ) / (e_high - e_low) * (@energy - e_low)
          else
            raise "Unexpected behaviour with index in the energy interpolation logic."
          end
        end
      end
    end
1337556
def _weighting(weights, exponent):
    """"""
    if np.isscalar(weights):
        weighting = NumpyTensorSpaceConstWeighting(weights, exponent)
    elif weights is None:
        weighting = NumpyTensorSpaceConstWeighting(1.0, exponent)
    else:  # last possibility: make an array
        arr = np.asarray(weights)
        weighting = NumpyTensorSpaceArrayWeighting(arr, exponent)
    return weighting
604791
def calcFnWeight(node):
    ''''''
    stack = [node]
    count = 0
    while len(stack) > 0:
        node = stack.pop()
        children = [x for x in ast.iter_child_nodes(node)]
        count += len(children)
        stack = stack + children
    return count
462192
def calcMzFromMass(mass, charge):
    
    mz = (mass + (maspy.constants.atomicMassProton * charge)) / charge
    return mz