-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ruben Horn
committed
Aug 12, 2024
1 parent
0909cb4
commit 9f1c3da
Showing
4 changed files
with
52 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,35 @@ | ||
import shutil | ||
from pathlib import Path | ||
|
||
|
||
def validate(get_config_value) -> str: | ||
key = __name__.split(".")[-1] | ||
use_checkpoint = get_config_value(key) | ||
domain_size = get_config_value("domain") | ||
solver_md = get_config_value("solver_md") | ||
if use_checkpoint and (domain_size > 1 or solver_md != "md"): | ||
return f"Example checkpoint file only provided for small Simple MD simulation." | ||
return None | ||
|
||
|
||
def apply(partial_xml, get_config_value) -> None: | ||
key = __name__.split(".")[-1] | ||
use_checkpoint = get_config_value(key) | ||
checkpoint_xml = '<checkpoint-configuration filename="CheckpointSimpleMD" write-every-timestep="0"></checkpoint-configuration>' | ||
partial_xml.substitute("checkpoint", checkpoint_xml if use_checkpoint else "") | ||
print("Substituted loading checkpoint") | ||
if use_checkpoint: | ||
boundary_condition = get_config_value("boundary") | ||
checkpoint_src_path = ( | ||
Path(__file__).parent.parent.parent | ||
/ "assets" | ||
/ f"CheckpointSimpleMD_10000_{boundary_condition}_0.checkpoint" | ||
) | ||
checkpoint_dst_path = ( | ||
Path(get_config_value("output_filename")).parent | ||
/ "CheckpointSimpleMD.checkpoint" | ||
) | ||
shutil.copyfile(checkpoint_src_path, checkpoint_dst_path) | ||
print( | ||
'TODO: Please make sure to provide the file "CheckpointSimpleMD.checkpoint" in the same directory as couette.xml!' | ||
'Also created file "CheckpointSimpleMD.checkpoint" in the same directory as couette.xml.' | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters