Skip to content

Commit c02d8d9

Browse files
authored
Merge pull request #180 from pyiron/outputkeys
Rename output parameter to output_keys
2 parents ffbb265 + 33bb53b commit c02d8d9

24 files changed

+97
-92
lines changed

atomistics/calculators/ase.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def evaluate_with_ase(
103103
return calc_static_with_ase(
104104
structure=structure,
105105
ase_calculator=ase_calculator,
106-
output=get_quantities_from_tasks(tasks=tasks),
106+
output_keys=get_quantities_from_tasks(tasks=tasks),
107107
)
108108
else:
109109
raise ValueError("The ASE calculator does not implement:", tasks)
@@ -113,28 +113,29 @@ def evaluate_with_ase(
113113
def calc_static_with_ase(
114114
structure,
115115
ase_calculator,
116-
output=OutputStatic.fields(),
116+
output_keys=OutputStatic.fields(),
117117
):
118118
return ASEOutputStatic.get(
119-
ASEExecutor(ase_structure=structure, ase_calculator=ase_calculator), *output
119+
ASEExecutor(ase_structure=structure, ase_calculator=ase_calculator),
120+
*output_keys,
120121
)
121122

122123

123124
def _calc_md_step_with_ase(
124-
dyn, structure, ase_calculator, temperature, run, thermo, output
125+
dyn, structure, ase_calculator, temperature, run, thermo, output_keys
125126
):
126127
structure.calc = ase_calculator
127128
MaxwellBoltzmannDistribution(atoms=structure, temperature_K=temperature)
128-
cache = {q: [] for q in output}
129+
cache = {q: [] for q in output_keys}
129130
for i in range(int(run / thermo)):
130131
dyn.run(thermo)
131132
calc_dict = ASEOutputMolecularDynamics.get(
132133
ASEExecutor(ase_structure=structure, ase_calculator=ase_calculator),
133-
*output,
134+
*output_keys,
134135
)
135136
for k, v in calc_dict.items():
136137
cache[k].append(v)
137-
return {q: np.array(cache[q]) for q in output}
138+
return {q: np.array(cache[q]) for q in output_keys}
138139

139140

140141
def calc_molecular_dynamics_npt_with_ase(
@@ -147,7 +148,7 @@ def calc_molecular_dynamics_npt_with_ase(
147148
pfactor=2e6 * units.GPa * (units.fs**2),
148149
temperature=100,
149150
externalstress=np.array([0.0, 0.0, 0.0, 0.0, 0.0, 0.0]) * units.bar,
150-
output=ASEOutputMolecularDynamics.fields(),
151+
output_keys=ASEOutputMolecularDynamics.fields(),
151152
):
152153
return _calc_md_step_with_ase(
153154
dyn=NPT(
@@ -169,7 +170,7 @@ def calc_molecular_dynamics_npt_with_ase(
169170
temperature=temperature,
170171
run=run,
171172
thermo=thermo,
172-
output=output,
173+
output_keys=output_keys,
173174
)
174175

175176

@@ -181,7 +182,7 @@ def calc_molecular_dynamics_langevin_with_ase(
181182
timestep=1 * units.fs,
182183
temperature=100,
183184
friction=0.002,
184-
output=ASEOutputMolecularDynamics.fields(),
185+
output_keys=ASEOutputMolecularDynamics.fields(),
185186
):
186187
return _calc_md_step_with_ase(
187188
dyn=Langevin(
@@ -195,7 +196,7 @@ def calc_molecular_dynamics_langevin_with_ase(
195196
temperature=temperature,
196197
run=run,
197198
thermo=thermo,
198-
output=output,
199+
output_keys=output_keys,
199200
)
200201

201202

@@ -231,7 +232,7 @@ def calc_molecular_dynamics_thermal_expansion_with_ase(
231232
ttime=100 * units.fs,
232233
pfactor=2e6 * units.GPa * (units.fs**2),
233234
externalstress=np.array([0.0, 0.0, 0.0, 0.0, 0.0, 0.0]) * units.bar,
234-
output=OutputThermalExpansionProperties.fields(),
235+
output_keys=OutputThermalExpansionProperties.fields(),
235236
):
236237
structure_current = structure.copy()
237238
temperature_lst = np.arange(
@@ -257,5 +258,5 @@ def calc_molecular_dynamics_thermal_expansion_with_ase(
257258
ThermalExpansionProperties(
258259
temperatures_lst=temperature_md_lst, volumes_lst=volume_md_lst
259260
),
260-
*output,
261+
*output_keys,
261262
)

atomistics/calculators/lammps/calculator.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def calc_static_with_lammps(
120120
structure,
121121
potential_dataframe,
122122
lmp=None,
123-
output=LammpsOutputStatic.fields(),
123+
output_keys=LammpsOutputStatic.fields(),
124124
**kwargs,
125125
):
126126
template_str = LAMMPS_THERMO_STYLE + "\n" + LAMMPS_THERMO + "\n" + LAMMPS_RUN
@@ -134,7 +134,7 @@ def calc_static_with_lammps(
134134
lmp=lmp,
135135
**kwargs,
136136
)
137-
result_dict = LammpsOutputStatic.get(lmp_instance, *output)
137+
result_dict = LammpsOutputStatic.get(lmp_instance, *output_keys)
138138
lammps_shutdown(lmp_instance=lmp_instance, close_instance=lmp is None)
139139
return result_dict
140140

@@ -151,7 +151,7 @@ def calc_molecular_dynamics_nvt_with_lammps(
151151
seed=4928459,
152152
dist="gaussian",
153153
lmp=None,
154-
output=LammpsOutputMolecularDynamics.fields(),
154+
output_keys=LammpsOutputMolecularDynamics.fields(),
155155
**kwargs,
156156
):
157157
init_str = (
@@ -187,7 +187,7 @@ def calc_molecular_dynamics_nvt_with_lammps(
187187
run_str=run_str,
188188
run=run,
189189
thermo=thermo,
190-
output=output,
190+
output_keys=output_keys,
191191
)
192192
lammps_shutdown(lmp_instance=lmp_instance, close_instance=lmp is None)
193193
return result_dict
@@ -208,7 +208,7 @@ def calc_molecular_dynamics_npt_with_lammps(
208208
seed=4928459,
209209
dist="gaussian",
210210
lmp=None,
211-
output=LammpsOutputMolecularDynamics.fields(),
211+
output_keys=LammpsOutputMolecularDynamics.fields(),
212212
**kwargs,
213213
):
214214
init_str = (
@@ -247,7 +247,7 @@ def calc_molecular_dynamics_npt_with_lammps(
247247
run_str=run_str,
248248
run=run,
249249
thermo=thermo,
250-
output=output,
250+
output_keys=output_keys,
251251
)
252252
lammps_shutdown(lmp_instance=lmp_instance, close_instance=lmp is None)
253253
return result_dict
@@ -266,7 +266,7 @@ def calc_molecular_dynamics_nph_with_lammps(
266266
seed=4928459,
267267
dist="gaussian",
268268
lmp=None,
269-
output=LammpsOutputMolecularDynamics.fields(),
269+
output_keys=LammpsOutputMolecularDynamics.fields(),
270270
**kwargs,
271271
):
272272
init_str = (
@@ -302,7 +302,7 @@ def calc_molecular_dynamics_nph_with_lammps(
302302
run_str=run_str,
303303
run=run,
304304
thermo=thermo,
305-
output=output,
305+
output_keys=output_keys,
306306
)
307307
lammps_shutdown(lmp_instance=lmp_instance, close_instance=lmp is None)
308308
return result_dict
@@ -320,7 +320,7 @@ def calc_molecular_dynamics_langevin_with_lammps(
320320
seed=4928459,
321321
dist="gaussian",
322322
lmp=None,
323-
output=LammpsOutputMolecularDynamics.fields(),
323+
output_keys=LammpsOutputMolecularDynamics.fields(),
324324
**kwargs,
325325
):
326326
init_str = (
@@ -358,7 +358,7 @@ def calc_molecular_dynamics_langevin_with_lammps(
358358
run_str=run_str,
359359
run=run,
360360
thermo=thermo,
361-
output=output,
361+
output_keys=output_keys,
362362
)
363363
lammps_shutdown(lmp_instance=lmp_instance, close_instance=lmp is None)
364364
return result_dict
@@ -380,7 +380,7 @@ def calc_molecular_dynamics_thermal_expansion_with_lammps(
380380
seed=4928459,
381381
dist="gaussian",
382382
lmp=None,
383-
output=OutputThermalExpansionProperties.fields(),
383+
output_keys=OutputThermalExpansionProperties.fields(),
384384
**kwargs,
385385
):
386386
init_str = (
@@ -411,7 +411,7 @@ def calc_molecular_dynamics_thermal_expansion_with_lammps(
411411
seed=seed,
412412
dist=dist,
413413
lmp=lmp,
414-
output=output,
414+
output_keys=output_keys,
415415
**kwargs,
416416
)
417417

@@ -457,7 +457,7 @@ def evaluate_with_lammps_library(
457457
structure=structure,
458458
potential_dataframe=potential_dataframe,
459459
lmp=lmp,
460-
output=get_quantities_from_tasks(tasks=tasks),
460+
output_keys=get_quantities_from_tasks(tasks=tasks),
461461
)
462462
else:
463463
raise ValueError("The LAMMPS calculator does not implement:", tasks)

atomistics/calculators/lammps/helpers.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,30 +46,30 @@ def lammps_calc_md_step(
4646
lmp_instance,
4747
run_str,
4848
run,
49-
output=LammpsOutputMolecularDynamics.fields(),
49+
output_keys=LammpsOutputMolecularDynamics.fields(),
5050
):
5151
run_str_rendered = Template(run_str).render(run=run)
5252
lmp_instance.interactive_lib_command(run_str_rendered)
53-
return LammpsOutputMolecularDynamics.get(lmp_instance, *output)
53+
return LammpsOutputMolecularDynamics.get(lmp_instance, *output_keys)
5454

5555

5656
def lammps_calc_md(
5757
lmp_instance,
5858
run_str,
5959
run,
6060
thermo,
61-
output=LammpsOutputMolecularDynamics.fields(),
61+
output_keys=LammpsOutputMolecularDynamics.fields(),
6262
):
6363
results_lst = [
6464
lammps_calc_md_step(
6565
lmp_instance=lmp_instance,
6666
run_str=run_str,
6767
run=thermo,
68-
output=output,
68+
output_keys=output_keys,
6969
)
7070
for _ in range(run // thermo)
7171
]
72-
return {q: np.array([d[q] for d in results_lst]) for q in output}
72+
return {q: np.array([d[q] for d in results_lst]) for q in output_keys}
7373

7474

7575
def lammps_thermal_expansion_loop(
@@ -88,7 +88,7 @@ def lammps_thermal_expansion_loop(
8888
seed=4928459,
8989
dist="gaussian",
9090
lmp=None,
91-
output=OutputThermalExpansionProperties.fields(),
91+
output_keys=OutputThermalExpansionProperties.fields(),
9292
**kwargs,
9393
):
9494
lmp_instance = lammps_run(
@@ -125,7 +125,7 @@ def lammps_thermal_expansion_loop(
125125
ThermalExpansionProperties(
126126
temperatures_lst=temperature_md_lst, volumes_lst=volume_md_lst
127127
),
128-
*output,
128+
*output_keys,
129129
)
130130

131131

atomistics/calculators/qe.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ def calc_static_with_qe(
186186
pseudopotentials=None,
187187
tstress=True,
188188
tprnfor=True,
189-
output=OutputStatic.fields(),
189+
output_keys=OutputStatic.fields(),
190190
**kwargs,
191191
):
192192
input_file_name = os.path.join(working_directory, calculation_name + ".pwi")
@@ -213,7 +213,7 @@ def calc_static_with_qe(
213213
calculation_name=calculation_name, working_directory=working_directory
214214
)
215215
return QuantumEspressoOutputStatic.get(
216-
QEStaticParser(filename=output_file_name), *output
216+
QEStaticParser(filename=output_file_name), *output_keys
217217
)
218218

219219

@@ -252,7 +252,7 @@ def evaluate_with_qe(
252252
pseudopotentials=pseudopotentials,
253253
tstress=tstress,
254254
tprnfor=tprnfor,
255-
output=get_quantities_from_tasks(tasks=tasks),
255+
output_keys=get_quantities_from_tasks(tasks=tasks),
256256
**kwargs,
257257
)
258258
else:

atomistics/workflows/elastic/workflow.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ def generate_structures(self):
4444
)
4545
return {"calc_energy": self._structure_dict}
4646

47-
def analyse_structures(self, output_dict, output=OutputElastic.fields()):
47+
def analyse_structures(self, output_dict, output_keys=OutputElastic.fields()):
4848
"""
4949
5050
Args:
5151
output_dict (dict):
52-
output (tuple):
52+
output_keys (tuple):
5353
5454
Returns:
5555
@@ -67,5 +67,5 @@ def analyse_structures(self, output_dict, output=OutputElastic.fields()):
6767
self._data["e0"] = ene0
6868
self._data["A2"] = A2
6969
return elastic_matrix_output_elastic.get(
70-
ElasticProperties(elastic_matrix=elastic_matrix), *output
70+
ElasticProperties(elastic_matrix=elastic_matrix), *output_keys
7171
)

atomistics/workflows/evcurve/debye.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ def get_thermal_properties(
232232
temperatures=None,
233233
constant_volume=False,
234234
num_steps=50,
235-
output=OutputThermodynamic.fields(),
235+
output_keys=OutputThermodynamic.fields(),
236236
):
237237
return DebyeOutputThermodynamic.get(
238238
DebyeThermalProperties(
@@ -245,5 +245,5 @@ def get_thermal_properties(
245245
constant_volume=constant_volume,
246246
num_steps=num_steps,
247247
),
248-
*output,
248+
*output_keys,
249249
)

atomistics/workflows/evcurve/workflow.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,9 @@ def generate_structures(self):
180180
self._structure_dict[1 + np.round(strain, 7)] = basis
181181
return {"calc_energy": self._structure_dict}
182182

183-
def analyse_structures(self, output_dict, output=OutputEnergyVolumeCurve.fields()):
183+
def analyse_structures(
184+
self, output_dict, output_keys=OutputEnergyVolumeCurve.fields()
185+
):
184186
self._fit_dict = EnergyVolumeCurveOutputEnergyVolumeCurve.get(
185187
EnergyVolumeCurveProperties(
186188
fit_module=fit_ev_curve_internal(
@@ -192,7 +194,7 @@ def analyse_structures(self, output_dict, output=OutputEnergyVolumeCurve.fields(
192194
fit_order=self.fit_order,
193195
)
194196
),
195-
*output,
197+
*output_keys,
196198
)
197199
return self.fit_dict
198200

@@ -206,7 +208,7 @@ def get_thermal_properties(
206208
t_step=50,
207209
temperatures=None,
208210
constant_volume=False,
209-
output=OutputThermodynamic.fields(),
211+
output_keys=OutputThermodynamic.fields(),
210212
):
211213
return get_thermal_properties(
212214
fit_dict=self.fit_dict,
@@ -216,5 +218,5 @@ def get_thermal_properties(
216218
t_step=t_step,
217219
temperatures=temperatures,
218220
constant_volume=constant_volume,
219-
output=output,
221+
output_keys=output_keys,
220222
)

0 commit comments

Comments
 (0)