Skip to content

Commit

Permalink
BUG: Fixed an issue wherein frozen atomic charges were ignored when n…
Browse files Browse the repository at this point in the history
…ot explicitly specified (#240)
  • Loading branch information
BvB93 committed May 26, 2021
1 parent f7c0489 commit 5e28609
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions FOX/armc/sanitization.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ def dict_to_armc(input_dict: MainMapping) -> Tuple[MonteCarloABC, RunDict]:
mc.pes_post_process = [AtomsFromPSF.from_psf(*psf_list)] # type: ignore[assignment]
workdir = Path(run_kwargs['path']) / run_kwargs['folder']
_update_psf_settings(package.values(), phi.phi, workdir) # type: ignore[arg-type]
_update_psf_charge(param, psf_list)

# Guess parameters
if _param_frozen is not None:
Expand Down Expand Up @@ -496,6 +497,18 @@ def _update_psf_settings(job_lists: Iterable[Iterable[MutableMapping[str, Any]]]
job['settings'].psf = os.path.join(workdir, f'mol.{i}.psf')


def _update_psf_charge(param: ParamMapping, psf_list: Iterable[PSFContainer]) -> None:
"""Add all (frozen) charges in the .psf files to the passed ``ParamMapping``."""
metadata = {'min': -np.inf, 'max': np.inf, 'count': 0, 'frozen': True,
'guess': False, 'unit': ''}

for i, psf in enumerate(psf_list):
charge_dict = {("charge", "charge", k): v for k, v in zip(psf.atom_type, psf.charge)}
for k, v in charge_dict.items(): # type: Tuple[str, str, str], float
if k not in param.param.index:
param.add_param(k, v, **metadata)


PrmTuple = Tuple[str, str, str, float]


Expand Down

0 comments on commit 5e28609

Please sign in to comment.