Skip to content

Commit

Permalink
fix timestep bug
Browse files Browse the repository at this point in the history
  • Loading branch information
srmnitc committed Oct 16, 2023
1 parent 18937f1 commit 53cba37
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 32 deletions.
1 change: 1 addition & 0 deletions calphy/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ def _validate_pair_style(self) -> 'Input':
def _validate_time(self) -> 'Input':
if np.isscalar(self.n_switching_steps):
self._n_sweep_steps = self.n_switching_steps
self._n_switching_steps = self.n_switching_steps
else:
self._n_sweep_steps = self.n_switching_steps[1]
self._n_switching_steps = self.n_switching_steps[0]
Expand Down
6 changes: 5 additions & 1 deletion calphy/routines.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,8 +513,12 @@ def routine_composition_scaling(job):

flambda_arr, w_arr, q_arr, qerr_arr = job.thermodynamic_integration()

job.logger.info('performing mass rescaling')
job.logger.info(f'Ref. mass is {ref_mass}')
job.logger.info(f'Target masses are {target_masses}')

#read the file
mcorrarr, mcorsum = job.mass_integration(flambda_arr, ref_mass, target_masses, target_counts)
mcorrarr, mcorsum = job.mass_integration(flambda_arr, target_masses, ref_mass, target_counts)
netfe = w_arr - mcorrarr

job.fe = job.fe - mcorsum
Expand Down
50 changes: 34 additions & 16 deletions examples/example_10/analysis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"id": "0072d247-40eb-467b-9b26-4efe2be4e66b",
"metadata": {},
"source": [
"In the file [`ZrCu.dump`](ZrCu.dump), CuZr in B2 structure is provided. The file [`ZrCu_substitution.dump`](ZrCu_substitution.dump) contains the same structure, but a single atom of Zr is replaced with Cu. If the free energy of both structures are calculated, the difference between the two provides the free energy change when a substitutional Cu atom is introduced.\n",
"In the file [`ZrCu.data`](ZrCu.data), CuZr in B2 structure is provided. The file [`ZrCu_substitution.data`](ZrCu_substitution.data) contains the same structure, but a single atom of Zr is replaced with Cu. If the free energy of both structures are calculated, the difference between the two provides the free energy change when a substitutional Cu atom is introduced.\n",
"\n",
"The input files for the direct calculations are [`input-direct-1.yaml`](input-direct-1.yaml) and [`input-direct-2.yaml`](input-direct-2.yaml). The calculations can be run by `calphy -i inputfilename`. Once the calculations are over, we can read in the results and analyse them."
]
Expand Down Expand Up @@ -69,8 +69,8 @@
"metadata": {},
"outputs": [],
"source": [
"fe_ref_direct = read_report(\"fe-ZrCu.dump-800-0\")\n",
"fe_sub_direct = read_report(\"fe-ZrCu_substitution.dump-800-0\")"
"fe_ref_direct = read_report(\"fe-zrcu.data-solid-800-0\")\n",
"fe_sub_direct = read_report(\"fe-zrcu_substitution.data-solid-800-0\")"
]
},
{
Expand All @@ -83,7 +83,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 3,
"id": "9255fe4d-a45d-46cb-b462-92dfe8586974",
"metadata": {},
"outputs": [],
Expand All @@ -102,17 +102,17 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 4,
"id": "476a6026-b44c-4ce8-b055-97bb07a2c465",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.0036244140356958+/-0.0005247047613173691"
"0.003912274087720213+/-9.587447227178194e-05"
]
},
"execution_count": 5,
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -131,9 +131,6 @@
"\n",
"```\n",
"composition_scaling:\n",
" input_chemical_composition:\n",
" - Cu: 512\n",
" - Zr: 512\n",
" output_chemical_composition:\n",
" - Cu: 513\n",
" - Zr: 511\n",
Expand All @@ -152,27 +149,27 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 5,
"id": "6633d120-1d07-4ae6-91bd-27c2ea16804a",
"metadata": {},
"outputs": [],
"source": [
"fe_sub_comp = read_report(\"sub-composition_scaling-ZrCu.dump-800-0\")"
"fe_sub_comp = read_report(\"sub-composition_scaling-zrcu.data-solid-800-0\")"
]
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 6,
"id": "a138085b-a32f-408a-a0e6-c71006fd3a30",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.0037993834787761636+/-1.1368085265609911e-05"
"0.0037949501379965674+/-6.960984850256015e-06"
]
},
"execution_count": 9,
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -182,6 +179,27 @@
"fe_sub_comp"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "2b51f5a7-d635-4cdc-83ef-a926ecfd0568",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.0038679727402182425"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"0.003831461439107405+3.6511301110837446e-05"
]
},
{
"cell_type": "markdown",
"id": "91e5c163-9f5e-4644-8994-e2e814cc35aa",
Expand Down Expand Up @@ -356,7 +374,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.6"
"version": "3.11.5"
}
},
"nbformat": 4,
Expand Down
10 changes: 4 additions & 6 deletions examples/example_10/input-composition.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
calculations:
- composition_scaling:
input_chemical_composition:
- Cu: 512
- Zr: 512
output_chemical_composition:
- Cu: 532
- Zr: 492
Cu: 532
Zr: 492
element:
- Zr
- Cu
lattice: ZrCu.dump
lattice: ZrCu.data
equilibration_control: berendsen
lattice_constant: 0.0
mass:
- 91.224
Expand Down
3 changes: 2 additions & 1 deletion examples/example_10/input-direct-1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ calculations:
- element:
- Zr
- Cu
lattice: ZrCu.dump
lattice: ZrCu.data
equilibration_control: berendsen
lattice_constant: 0.0
mass:
- 91.224
Expand Down
3 changes: 2 additions & 1 deletion examples/example_10/input-direct-2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ calculations:
- element:
- Zr
- Cu
lattice: ZrCu_substitution.dump
lattice: ZrCu_substitution.data
equilibration_control: berendsen
lattice_constant: 0.0
mass:
- 91.224
Expand Down
12 changes: 5 additions & 7 deletions examples/example_10/input-substitution.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
calculations:
- composition_scaling:
input_chemical_composition:
- Cu: 512
- Zr: 512
output_chemical_composition:
- Cu: 513
- Zr: 511
Cu: 513
Zr: 511
element:
- Zr
- Cu
folder_prefix: sub
lattice: ZrCu.dump
lattice: ZrCu.data
equilibration_control: berendsen
lattice_constant: 0.0
mass:
- 91.224
- 63.546
mode: composition_scaling
n_equilibration_steps: 5000
n_iterations: 3
n_iterations: 1
n_switching_steps: 5000
pair_coeff: '* * ../potentials/ZrCu.eam.fs Zr Cu'
pair_style: eam/fs
Expand Down

0 comments on commit 53cba37

Please sign in to comment.