Skip to content

Commit

Permalink
Separate exact, sampling and approximation
Browse files Browse the repository at this point in the history
  • Loading branch information
WardLT committed Oct 3, 2023
1 parent f3e6406 commit 865cd71
Show file tree
Hide file tree
Showing 13 changed files with 1,710 additions and 1,359 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
},
"outputs": [],
"source": [
"from ase.calculators.mopac import MOPAC\n",
"from ase.calculators.psi4 import Psi4\n",
"from jitterbug.utils import make_calculator\n",
"from ase.io import write, read\n",
"from ase.db import connect\n",
"from ase import Atoms\n",
Expand All @@ -40,21 +39,17 @@
{
"cell_type": "code",
"execution_count": 2,
"id": "c6be56c5-a460-4acd-9b89-8c3d9c812f5f",
"id": "52252ee2-315c-48bb-8cba-07620e6e2faa",
"metadata": {
"tags": [
"parameters"
]
},
"outputs": [],
"source": [
"molecule_name = 'caffeine'\n",
"method = 'pm7'\n",
"mopac_methods = ['pm7'] # Use MOPAC for these methods\n",
"basis = None # Set to None for MOPAC methods\n",
"starting_geometry = '../data/exact/water_b3lyp_def2-svpd.xyz'\n",
"threads = min(os.cpu_count(), 12)\n",
"step_size: float = 0.01 # Perturbation amount, used as maximum L2 norm\n",
"assert (method in mopac_methods) == (basis is None), 'Use a basis of None for MOPAC computations'"
"step_size: float = 0.005 # Perturbation amount, used as maximum L2 norm"
]
},
{
Expand All @@ -72,7 +67,8 @@
"metadata": {},
"outputs": [],
"source": [
"run_name = f'{molecule_name}_{method}_{basis}'"
"run_name = Path(starting_geometry).name[:-4]\n",
"name, method, basis = run_name.split(\"_\")"
]
},
{
Expand All @@ -95,7 +91,7 @@
{
"data": {
"text/plain": [
"Atoms(symbols='O2N4C8H10', pbc=False, forces=..., calculator=SinglePointCalculator(...))"
"Atoms(symbols='OH2', pbc=False, forces=..., calculator=SinglePointCalculator(...))"
]
},
"execution_count": 4,
Expand All @@ -104,7 +100,7 @@
}
],
"source": [
"atoms = read(Path('data') / 'exact' / f'{run_name}.xyz')\n",
"atoms = read(starting_geometry)\n",
"atoms"
]
},
Expand Down Expand Up @@ -134,8 +130,8 @@
},
"outputs": [],
"source": [
"out_dir = Path('data') / 'approx'\n",
"out_dir.mkdir(exist_ok=True)"
"out_dir = Path('data') / 'random-dir-same-dist'\n",
"out_dir.mkdir(exist_ok=True, parents=True)"
]
},
{
Expand All @@ -147,7 +143,7 @@
},
"outputs": [],
"source": [
"db_path = out_dir / f'{run_name}-random-d={step_size:.2e}.db'"
"db_path = out_dir / f'{run_name}_d={step_size:.2e}.db'"
]
},
{
Expand Down Expand Up @@ -187,12 +183,17 @@
"metadata": {
"tags": []
},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" Threads set to 1 by Python driver.\n"
]
}
],
"source": [
"if method not in mopac_methods:\n",
" calc = Psi4(method=method, basis=basis, num_threads=threads, memory='4096MB')\n",
"else:\n",
" calc = MOPAC(method=method, command='mopac PREFIX.mop > /dev/null')"
"calc = make_calculator(method, basis, threads=threads)"
]
},
{
Expand All @@ -215,7 +216,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Need to run 2701 calculations for full accuracy.\n"
"Need to run 55 calculations for full accuracy.\n"
]
}
],
Expand All @@ -237,7 +238,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Already done 1. 2700 left to do.\n"
"Already done 1. 54 left to do.\n"
]
}
],
Expand All @@ -257,7 +258,21 @@
"name": "stderr",
"output_type": "stream",
"text": [
"100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2701/2701 [03:10<00:00, 19.27it/s]"
" 0%| | 0/55 [00:00<?, ?it/s]"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
" Threads set to 1 by Python driver.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 55/55 [00:40<00:00, 1.30it/s]"
]
}
],
Expand Down
Loading

0 comments on commit 865cd71

Please sign in to comment.