From 8497b3e4a9b7af28b4cbe002d3a5a8e16a31a53d Mon Sep 17 00:00:00 2001 From: Sarath Menon Date: Wed, 27 Sep 2023 17:56:38 +0200 Subject: [PATCH] further fixes --- calphy/alchemy.py | 2 +- calphy/input.py | 28 ++++++++++++++++++++++++---- calphy/phase.py | 4 ++-- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/calphy/alchemy.py b/calphy/alchemy.py index d51e018..39a9503 100644 --- a/calphy/alchemy.py +++ b/calphy/alchemy.py @@ -160,7 +160,7 @@ def run_integration(self, iteration=1): lmp.command("velocity all create %f %d mom yes rot yes dist gaussian"%(self.calc._temperature, np.random.randint(1, 10000))) # Integrator & thermostat. - if self.calc._npt: + if self.calc.npt: lmp.command("fix f1 all npt temp %f %f %f %s %f %f %f"%(self.calc._temperature, self.calc._temperature, self.calc.md.thermostat_damping[1], self.iso, self.calc._pressure, self.calc._pressure, self.calc.md.barostat_damping[1])) else: diff --git a/calphy/input.py b/calphy/input.py index f9f7bbb..4971bf6 100644 --- a/calphy/input.py +++ b/calphy/input.py @@ -251,7 +251,7 @@ def _validate_temperature(self) -> 'Input': if self._temperature_high is None: self._temperature_high = 2*temp[0] elif np.shape(self.temperature) == (2,): - temp = self.temperature_input + temp = self.temperature self._temperature = temp[0] self._temperature_stop = temp[1] if self._temperature_high is None: @@ -557,11 +557,12 @@ def _convert_legacy_inputfile(file): "melting_cycle", "equilibration_control", "folder_prefix", "temperature_high"]: if key in ci.keys(): calc[key] = ci[key] + #print(combo) calc["lattice"] = str(combo[0]["lattice"]) calc["lattice_constant"] = float(combo[0]["lattice_constant"]) calc["reference_phase"] = str(combo[0]["reference_phase"]) - calc["pressure"] = float(combo[1]) - calc["temperature"] = float(combo[2]) + calc["pressure"] = _to_float(combo[1]) + calc["temperature"] = _to_float(combo[2]) calculations.append(calc) newdata = {} @@ -571,4 +572,23 @@ def _convert_legacy_inputfile(file): warnings.warn(f'Old style input file calphy < v2 found. Converted input in {outfile}. Please check!') with open(outfile, 'w') as fout: yaml.safe_dump(newdata, fout) - return outfile \ No newline at end of file + return outfile + + +def _to_str(val): + if np.isscalar(val): + return str(val) + else: + return [str(x) for x in val] + +def _to_int(val): + if np.isscalar(val): + return int(val) + else: + return [int(x) for x in val] + +def _to_float(val): + if np.isscalar(val): + return float(val) + else: + return [float(x) for x in val] \ No newline at end of file diff --git a/calphy/phase.py b/calphy/phase.py index 873b027..1e6353d 100644 --- a/calphy/phase.py +++ b/calphy/phase.py @@ -804,7 +804,7 @@ def reversible_scaling(self, iteration=1): lmp = ph.remap_box(lmp, self.lx, self.ly, self.lz) #set thermostat and run equilibrium - if self.calc._npt: + if self.calc.npt: lmp.command("fix f1 all npt temp %f %f %f %s %f %f %f"%(t0, t0, self.calc.md.thermostat_damping[1], self.iso, pi, pi, self.calc.md.barostat_damping[1])) else: @@ -818,7 +818,7 @@ def reversible_scaling(self, iteration=1): lmp.command("variable ycm equal xcm(all,y)") lmp.command("variable zcm equal xcm(all,z)") - if self.calc._npt: + if self.calc.npt: lmp.command("fix f1 all npt temp %f %f %f %s %f %f %f fixedpoint ${xcm} ${ycm} ${zcm}"%(t0, t0, self.calc.md.thermostat_damping[1], self.iso, pi, pi, self.calc.md.barostat_damping[1])) else: