Skip to content

Commit

Permalink
add potential file keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
srmnitc committed Apr 5, 2022
1 parent c92df79 commit 46e5429
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 deletions.
14 changes: 13 additions & 1 deletion calphy/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def __init__(self):
self._fix_lattice = False
self._pair_style = None
self._pair_coeff = None
self._potential_file = None
self._reference_phase = None
self._lattice_constant = 0
self._repeat = [1, 1, 1]
Expand Down Expand Up @@ -316,6 +317,17 @@ def pair_coeff(self, val):
val = self.fix_paths(val)
self._pair_coeff = val

@property
def potential_file(self):
return self._potential_file

@potential_file.setter
def potential_file(self, val):
if os.path.exists(val):
self._potential_file = val
else:
raise FileNotFoundError("File %s not found"%val)

@property
def reference_phase(self):
return self._reference_phase
Expand Down Expand Up @@ -577,7 +589,7 @@ def read_inputfile(file):
for combo in combos:
calc = Calculation.generate(indata)
calc.from_dict(ci, keys=["mode", "pair_style", "pair_coeff", "repeat", "n_equilibration_steps",
"n_switching_steps", "n_print_steps", "n_iterations"])
"n_switching_steps", "n_print_steps", "n_iterations", "potential_file"])
calc.lattice = combo[0]["lattice"]
calc.lattice_constant = combo[0]["lattice_constant"]
calc.reference_phase = combo[0]["reference_phase"]
Expand Down
10 changes: 8 additions & 2 deletions calphy/solid.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ def run_averaging(self):
lmp = ph.create_structure(lmp, self.calc)

#set up potential
lmp = ph.set_potential(lmp, self.calc)
if self.calc.potential_file is None:
lmp = ph.set_potential(lmp, self.calc)
else:
lmp.command("include %s"%self.calc.potential_file)

#add some computes
lmp.command("variable mvol equal vol")
Expand Down Expand Up @@ -310,7 +313,10 @@ def run_integration(self, iteration=1):
lmp = ph.read_dump(lmp, conf, species=self.calc.n_elements)

#set up potential
lmp = ph.set_potential(lmp, self.calc)
if self.calc.potential_file is None:
lmp = ph.set_potential(lmp, self.calc)
else:
lmp.command("include %s"%self.calc.potential_file)

#remap the box to get the correct pressure
lmp = ph.remap_box(lmp, self.lx, self.ly, self.lz)
Expand Down
15 changes: 14 additions & 1 deletion docs/source/documentation/inputfile.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The inputfile is `yaml` formatted. In this section the possible keys in the inpu
| :-: | :-: | :-: | :-: | :-: |
| [mode](#mode) | [lattice](#lattice) | [reference_phase](#reference_phase) | [temperature](#temperature) | [pressure](#pressure) |
| [temperature_high](#temperature_high) | [lattice_constant](#lattice_constant) | [repeat](#repeat) | [n_iterations](#n_iterations) | [n_switching_steps](#n_switching_steps) |
| [n_equilibration_steps](#n_equilibration_steps) | [pair_style](#pair_style) | [pair_coeff](#pair_coeff) | [n_print_steps](#n_print_steps) |
| [n_equilibration_steps](#n_equilibration_steps) | [pair_style](#pair_style) | [pair_coeff](#pair_coeff) | [n_print_steps](#n_print_steps) | [potential_file](#potential_file) |

| `md` block | | | | |
| :-: | :-: | :-: | :-: | :-: |
Expand Down Expand Up @@ -279,6 +279,19 @@ The [pair coeff](https://lammps.sandia.gov/doc/pair_coeff.html) command for LAMM

---

#### <a name="potential_file"></a>`potential_file`

_type_: string
_default_: None
_example_:
```
pair_coeff: "/home/calc/potential.inp"
```

If specified, the `pair_style` and `pair_coeff` commands are not used, but rather the potential is read in from the provided input file using `include` command in LAMMPS. This allows the use of more complex or multiple potential files. Due to the `hybrid/scaled` styles employed in calphy, **this option only works with mode `fe` and `reference_phase` solid.**

---

#### <a name="n_equilibration_steps"></a>`n_equilibration_steps`

_type_: int
Expand Down

0 comments on commit 46e5429

Please sign in to comment.