Skip to content

update: add a new option of absolute volume in /dpgen/dpgen/auto_test/EOS.py #741

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 12, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions doc/toymodels/JiamengHuang_pr.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
A new parameter "vol_abs" is added. If you want to use absolute volume to get EOS, you can add

"vol_abs": true,

in the "eos" part of property.json
if it's not mentioned, "False" is set defaultly
when you are using absolute volume, there will be a notation in the last line of output during "make" process, which is like

treat vol_start and vol_end as absolute volume
15 changes: 13 additions & 2 deletions dpgen/auto_test/EOS.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ def __init__(self,
self.vol_start = parameter['vol_start']
self.vol_end = parameter['vol_end']
self.vol_step = parameter['vol_step']
parameter['vol_abs'] = parameter.get('vol_abs', False)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set_default is better than get.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get is applied in other parts of dpgen. To keep consistency, I think it's ok.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you mean the other parts in this file, indeed I don't think they are ok. Here set_default is faster and more concise. I can approve this PR though.

self.vol_abs = parameter['vol_abs']
parameter['cal_type'] = parameter.get('cal_type', 'relaxation')
self.cal_type = parameter['cal_type']
default_cal_setting = {"relax_pos": True,
Expand Down Expand Up @@ -117,6 +119,10 @@ def make_confs(self,

else:
print('gen eos from ' + str(self.vol_start) + ' to ' + str(self.vol_end) + ' by every ' + str(self.vol_step))
if self.vol_abs :
print('treat vol_start and vol_end as absolute volume')
else :
print('treat vol_start and vol_end as relative volume')
equi_contcar = os.path.join(path_to_equi, 'CONTCAR')
if not os.path.exists(equi_contcar):
raise RuntimeError("please do relaxation first")
Expand All @@ -138,8 +144,13 @@ def make_confs(self,
task_list.append(output_task)
os.symlink(os.path.relpath(equi_contcar), 'POSCAR.orig')
# scale = (vol / vol_to_poscar) ** (1. / 3.)
scale = vol ** (1. / 3.)
eos_params = {'volume': vol * vol_to_poscar, 'scale': scale}

if self.vol_abs :
scale = (vol / vol_to_poscar) ** (1. / 3.)
eos_params = {'volume': vol, 'scale': scale}
else :
scale = vol ** (1. / 3.)
eos_params = {'volume': vol * vol_to_poscar, 'scale': scale}
dumpfn(eos_params, 'eos.json', indent=4)
self.parameter['scale2equi'].append(scale) # 06/22
vasp.poscar_scale('POSCAR.orig', 'POSCAR', scale)
Expand Down