Example #1
0
    def OnConvert(self, event):
        try:
            fvalue = float(self.from_textctrl.GetValue())
        except:
            awx.showErrorMessage(self)
            return

        from_unit = self.from_unit_choice.GetValue()
        if from_unit == "foo":
            from abipy.gui.awx.eggs import Puzzle
            return Puzzle(self)

        ufloat = units.FloatWithUnit(fvalue, from_unit)
        to_unit = self.to_unit_choice.GetValue()

        try:
            conversion = ufloat.to(to_unit)
            print(ufloat, conversion)
            self.to_textctrl.SetValue(str(float(conversion)))

        except:
            awx.showErrorMessage(self)
Example #2
0
 def pressure(self):
     """Pressure in GPa."""
     pressure = -self.cart_stress_tensor.trace() / 3
     return units.FloatWithUnit(pressure, unit="GPa", unit_type="pressure")
Example #3
0
 def pressure(self):
     """Pressure in Gpa"""
     HaBohr3_GPa = 29421.033 # 1 Ha/Bohr^3, in GPa
     pressure = - (HaBohr3_GPa/3) * self.cart_stress_tensor.trace()
     return units.FloatWithUnit(pressure, unit="GPa", unit_type="pressure")