Exemplo n.º 1
0
 def read_cart_forces(self, unit="eV ang^-1"):
     """
     Read and return a |numpy-array| with the cartesian forces in unit ``unit``.
     Shape (num_steps, natom, 3)
     """
     return units.ArrayWithUnit(self.read_value("fcart"),
                                "Ha bohr^-1").to(unit)
Exemplo n.º 2
0
    def fit(self, volumes, energies, vol_unit="ang^3", ene_unit="eV"):
        """
        Fit energies [eV] as function of volumes [Angstrom**3].

        Returns `EosFit` instance that gives access to the optimal volume,
        the minumum energy, and the bulk modulus.
        Notice that the units for the bulk modulus is eV/Angstrom^3.
        """
        # Convert volumes to Ang**3 and energies to eV (if needed).
        volumes = units.ArrayWithUnit(volumes, vol_unit).to("ang^3")
        energies = units.EnergyArray(energies, ene_unit).to("eV")

        return EOS_Fit(volumes, energies, self._func, self._eos_name)
Exemplo n.º 3
0
    def get_fstats_dict(self, step):
        """
        Return |AttrDict| with stats on the forces at the given ``step``.
        """
        # [time, natom, 3]
        var = self.reader.read_variable("fcart")
        forces = units.ArrayWithUnit(var[step], "Ha bohr^-1").to("eV ang^-1")
        fmods = np.array([np.linalg.norm(force) for force in forces])

        return AttrDict(
            fmin=fmods.min(),
            fmax=fmods.max(),
            fmean=fmods.mean(),
            fstd=fmods.std(),
            drift=np.linalg.norm(forces.sum(axis=0)),
        )
Exemplo n.º 4
0
    def fit(self, volumes, energies, vol_unit="ang^3", energy_unit="eV"):
        """
        Fit energies (in eV) as function of volumes (in Angstrom**3).

        Args:
            volumes (list/np.array)
            energies (list/np.array)
            vol_unit (str): volume units
            energy_unit (str): energy units

        Returns:
            EOSFit: EOSFit object that gives access to the optimal volume,
                the minumum energy, and the bulk modulus.

            Note: the units for the bulk modulus is eV/Angstrom^3.
        """
        # Convert volumes to Ang**3 and energies to eV (if needed).
        volumes = units.ArrayWithUnit(volumes, vol_unit).to("ang^3")
        energies = units.EnergyArray(energies, energy_unit).to("eV")

        return EOSFit(volumes, energies, self._func, self._eos_name)