-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nd restart tests #809
base: master
Are you sure you want to change the base?
nd restart tests #809
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -1,7 +1,10 @@ | ||||||||
import unittest | ||||||||
|
||||||||
from copy import deepcopy | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider separating imports on individual lines for clarity. - from datetime import datetime
+ import datetime Committable suggestion
Suggested change
|
||||||||
|
||||||||
|
||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Multiple imports on one line. - from datetime import datetime
+ import datetime Committable suggestion
Suggested change
|
||||||||
from datetime import datetime | ||||||||
import pyphare.pharein as ph, numpy as np | ||||||||
from pyphare.pharein import ElectronModel | ||||||||
|
||||||||
|
||||||||
def parse_cli_args(pop_from_sys=True): | ||||||||
|
@@ -30,31 +33,33 @@ def basicSimulatorArgs(dim: int, interp: int, **kwargs): | |||||||
from pyphare.pharein.simulation import valid_refined_particle_nbr | ||||||||
from pyphare.pharein.simulation import check_patch_size | ||||||||
|
||||||||
args = deepcopy(kwargs) | ||||||||
|
||||||||
cells = kwargs.get("cells", [20 for i in range(dim)]) | ||||||||
if not isinstance(cells, (list, tuple)): | ||||||||
cells = [cells] * dim | ||||||||
|
||||||||
_, smallest_patch_size = check_patch_size(dim, interp_order=interp, cells=cells) | ||||||||
dl = [1.0 / v for v in cells] | ||||||||
b0 = [[3] * dim, [8] * dim] | ||||||||
|
||||||||
args = { | ||||||||
"interp_order": interp, | ||||||||
"smallest_patch_size": smallest_patch_size, | ||||||||
"largest_patch_size": [20] * dim, | ||||||||
"time_step_nbr": 1000, | ||||||||
"final_time": 1.0, | ||||||||
"time_step": 0.001, | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider making |
||||||||
"boundary_types": ["periodic"] * dim, | ||||||||
"cells": cells, | ||||||||
"dl": dl, | ||||||||
"refinement_boxes": {"L0": {"B0": b0}}, | ||||||||
"dl": [1.0 / v for v in cells], | ||||||||
"refined_particle_nbr": valid_refined_particle_nbr[dim][interp][0], | ||||||||
"diag_options": {}, | ||||||||
"nesting_buffer": 0, | ||||||||
"strict": True, | ||||||||
# "strict": True, | ||||||||
} | ||||||||
for k, v in kwargs.items(): | ||||||||
if k in args: | ||||||||
args[k] = v | ||||||||
args.update(deepcopy(kwargs)) | ||||||||
|
||||||||
if "refinement" not in kwargs and "refinement_boxes" not in kwargs: | ||||||||
b0 = [[3] * dim, [8] * dim] | ||||||||
args["refinement_boxes"] = {"L0": {"B0": b0}} | ||||||||
Comment on lines
+60
to
+62
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The condition to set |
||||||||
|
||||||||
return args | ||||||||
|
||||||||
|
@@ -139,20 +144,20 @@ def makeBasicModel(extra_pops={}): | |||||||
) | ||||||||
|
||||||||
|
||||||||
def populate_simulation(dim, interp, **input): | ||||||||
def populate_simulation(ndim=1, interp=1, model_fn=None, diags_fn=None, **simInput): | ||||||||
ph.global_vars.sim = None | ||||||||
simulation = ph.Simulation(**basicSimulatorArgs(dim, interp, **input)) | ||||||||
simulation = ph.Simulation(**basicSimulatorArgs(ndim, interp, **simInput)) | ||||||||
extra_pops = {} | ||||||||
if "populations" in input: | ||||||||
for pop, vals in input["populations"].items(): | ||||||||
if "populations" in simInput: | ||||||||
for pop, vals in simInput["populations"].items(): | ||||||||
extra_pops[pop] = defaultPopulationSettings() | ||||||||
extra_pops[pop].update(vals) | ||||||||
|
||||||||
model = makeBasicModel(extra_pops) | ||||||||
if "diags_fn" in input: | ||||||||
input["diags_fn"](model) | ||||||||
model = model_fn() if model_fn else makeBasicModel(extra_pops) | ||||||||
if diags_fn: | ||||||||
diags_fn(model) | ||||||||
|
||||||||
ElectronModel(closure="isothermal", Te=0.12) | ||||||||
ph.ElectronModel(closure="isothermal", Te=0.12) | ||||||||
Comment on lines
+147
to
+160
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tip Codebase Verification The verification process has identified that the function
It is recommended to update these calls to match the new function signature to ensure consistency and functionality throughout the codebase. Analysis chainEnsure all calls to Scripts ExecutedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Verify all function calls to `populate_simulation` match the new signature.
# Test: Search for the old function signature to find omissions. Expect: No matches.
ast-grep --lang python --pattern $'populate_simulation($_, $_)'
# Test: Search for the new function signature to validate usage. Expect: Matches.
ast-grep --lang python --pattern $'populate_simulation($_, $_, $_, $_, $$$)'
Length of output: 2207 |
||||||||
|
||||||||
return simulation | ||||||||
|
||||||||
|
@@ -260,3 +265,11 @@ def clean_up_diags_dirs(self): | |||||||
for diag_dir in self.diag_dirs: | ||||||||
if os.path.exists(diag_dir): | ||||||||
shutil.rmtree(diag_dir) | ||||||||
|
||||||||
def hierarchy_by_box(self, hier): | ||||||||
# comparing hierarchies by index isn't always right | ||||||||
box_hier = {i: {} for i in range(len(hier.levels()))} | ||||||||
for ilvl, patches in box_hier.items(): | ||||||||
for patch in hier.level(ilvl).patches: | ||||||||
patches[str(patch.box)] = patch | ||||||||
return box_hier | ||||||||
Comment on lines
+269
to
+275
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add unit tests for the Would you like me to generate unit tests for the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is used as part of a test. so it is tested. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @PhilipDeegan, I've verified that the Thank you for the clarification! Analysis chainScripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Search for invocations of the `hierarchy_by_box` method within the test files.
rg 'hierarchy_by_box' tests/
Length of output: 183 |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
without this, running multiple instances of mpirun -n 2 python3 ... effectively only lets run one process, the rest are descheduled until the first is finished
we could not default it here but set it manually in TC builds, or have it as an option defaulted to ON
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was moved to the configurator, so to rm