-
Notifications
You must be signed in to change notification settings - Fork 93
/
eos.py
46 lines (32 loc) · 1.48 KB
/
eos.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from __future__ import print_function, division, unicode_literals, absolute_import
import wx
import abipy.gui.awx as awx
from pymatgen.analysis.eos import EOS
class EosFrame(awx.Frame):
"""
Frame that allows the user to fit E(V).
"""
def __init__(self, parent, volumes, energies, vol_unit="ang^3", ene_unit="eV", **kwargs):
super(EosFrame, self).__init__(parent, id=-1, title="EOS Frame", **kwargs)
self.volumes, self.vol_unit = volumes, vol_unit
self.energies, self.ene_unit = energies, ene_unit
self.BuildUi()
def BuildUi(self):
main_sizer = wx.BoxSizer(wx.VERTICAL)
models = EOS.MODELS.keys()
self.model_choice = wx.Choice(self, -1, wx.DefaultPosition, wx.DefaultSize, models, 0)
self.model_choice.SetSelection(0)
main_sizer.Add(self.model_choice, 0, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL | wx.EXPAND, 5)
fit_button = wx.Button(self, -1, "Plot", wx.DefaultPosition, wx.DefaultSize, 0)
fit_button.Bind(wx.EVT_BUTTON, self.OnFitButton)
main_sizer.Add(fit_button, 0, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL, 5)
self.SetSizerAndFit(main_sizer)
def OnFitButton(self, event):
model = self.model_choice.GetStringSelection()
try:
eos = EOS(eos_name=model)
fit = eos.fit(self.volumes, self.energies, vol_unit=self.vol_unit, ene_unit=self.ene_unit)
print(fit)
fit.plot()
except:
awx.showErrorMessage(self)