-
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
Mpi nightly build trials #917
base: master
Are you sure you want to change the base?
Changes from all commits
990e748
c736a9b
3275fc7
a404062
5288a5c
e41c5ef
45db18b
175c459
69bc76b
0c503d3
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 |
---|---|---|
|
@@ -11,42 +11,46 @@ | |
from pyphare.simulator.simulator import Simulator, startMPI | ||
|
||
from tests.simulator import SimulatorTest | ||
from tools.python3 import plotting as m_plotting | ||
|
||
import harris_2d as base | ||
|
||
mpl.use("Agg") | ||
|
||
SCOPE_TIMING = os.getenv("PHARE_SCOPE_TIMING", "True").lower() in ("true", "1", "t") | ||
SCOPE_TIMING = os.getenv("PHARE_SCOPE_TIMING", "False").lower() in ("true", "1", "t") | ||
""" | ||
For scope timings to work | ||
The env var PHARE_SCOPE_TIMING must be == "1" (or "true") | ||
See src/phare/phare.hpp | ||
CMake must be configured with: -DwithPhlop=ON | ||
And a LOG_LEVEL must be defined via compile args: -DPHARE_LOG_LEVEL=1 | ||
Or change the default value in src/core/logger.hpp | ||
And phlop must be available on PYTHONPATH either from subprojects | ||
or install phlop via pip | ||
""" | ||
|
||
LOAD_BALANCE = os.getenv("LOAD_BALANCE", "True").lower() in ("true", "1", "t") | ||
|
||
cpp = cpp_lib() | ||
startMPI() | ||
|
||
cells = (800, 800) | ||
time_step = 0.005 | ||
cells = (100, 100) | ||
final_time = 50 | ||
time_step = 0.005 | ||
timestamps = np.arange(0, final_time + time_step, final_time / 5) | ||
|
||
if cpp.mpi_rank() == 0: | ||
print(LOAD_BALANCE, "diag timestamps:", timestamps) | ||
|
||
diag_dir = "phare_outputs/harris_lb" | ||
if not LOAD_BALANCE: | ||
diag_dir = "phare_outputs/harris" | ||
|
||
diag_dir = "phare_outputs/harris_2d_100_x_100" | ||
plot_dir = Path(f"{diag_dir}_plots") | ||
plot_dir.mkdir(parents=True, exist_ok=True) | ||
|
||
|
||
def config(): | ||
L = 0.5 | ||
|
||
sim = ph.Simulation( | ||
time_step=time_step, | ||
final_time=final_time, | ||
cells=cells, | ||
dl=(0.40, 0.40), | ||
refinement="tagging", | ||
max_nbr_levels=2, | ||
# refinement="tagging", | ||
# max_nbr_levels=1, | ||
Comment on lines
+52
to
+53
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. 💡 Codebase verification Commented parameters are actively used in other Harris tests The commented-out parameters are actively used in other test files:
No evidence found of these parameters being moved to a base configuration. Removing them might affect test consistency with other Harris simulations. 🔗 Analysis chainVerify impact of disabled refinement parameters. The commented-out parameters might affect simulation accuracy: # refinement="tagging"
# max_nbr_levels=1 Please clarify if disabling these parameters is intentional and how it affects the simulation results. 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Check usage of refinement parameters in other tests
echo "Checking refinement parameter usage..."
rg -l "refinement.*tagging" tests/functional/
rg -l "max_nbr_levels" tests/functional/
Length of output: 455 Script: #!/bin/bash
# Look for base config file
echo "Searching for base config..."
fd "base.config"
# Check actual parameter usage
echo -e "\nChecking parameter usage in test files..."
rg "refinement.*=.*tagging" tests/functional/ -B2 -A2
rg "max_nbr_levels.*=.*\d+" tests/functional/ -B2 -A2
Length of output: 2761 |
||
nesting_buffer=1, | ||
clustering="tile", | ||
tag_buffer="1", | ||
|
@@ -56,91 +60,16 @@ def config(): | |
"format": "phareh5", | ||
"options": {"dir": diag_dir, "mode": "overwrite"}, | ||
}, | ||
restart_options={ | ||
"dir": "checkpoints", | ||
"mode": "overwrite", | ||
"timestamps": timestamps, | ||
# "restart_time": 0.0, | ||
}, | ||
) | ||
|
||
def density(x, y): | ||
Ly = sim.simulation_domain()[1] | ||
return ( | ||
0.4 | ||
+ 1.0 / np.cosh((y - Ly * 0.3) / L) ** 2 | ||
+ 1.0 / np.cosh((y - Ly * 0.7) / L) ** 2 | ||
) | ||
|
||
def S(y, y0, l): | ||
return 0.5 * (1.0 + np.tanh((y - y0) / l)) | ||
|
||
def by(x, y): | ||
Lx = sim.simulation_domain()[0] | ||
Ly = sim.simulation_domain()[1] | ||
sigma = 1.0 | ||
dB = 0.1 | ||
|
||
x0 = x - 0.5 * Lx | ||
y1 = y - 0.3 * Ly | ||
y2 = y - 0.7 * Ly | ||
|
||
dBy1 = 2 * dB * x0 * np.exp(-(x0**2 + y1**2) / (sigma) ** 2) | ||
dBy2 = -2 * dB * x0 * np.exp(-(x0**2 + y2**2) / (sigma) ** 2) | ||
|
||
return dBy1 + dBy2 | ||
|
||
def bx(x, y): | ||
Lx = sim.simulation_domain()[0] | ||
Ly = sim.simulation_domain()[1] | ||
sigma = 1.0 | ||
dB = 0.1 | ||
sim = base.config(sim, timestamps) | ||
|
||
x0 = x - 0.5 * Lx | ||
y1 = y - 0.3 * Ly | ||
y2 = y - 0.7 * Ly | ||
|
||
dBx1 = -2 * dB * y1 * np.exp(-(x0**2 + y1**2) / (sigma) ** 2) | ||
dBx2 = 2 * dB * y2 * np.exp(-(x0**2 + y2**2) / (sigma) ** 2) | ||
|
||
v1 = -1 | ||
v2 = 1.0 | ||
return v1 + (v2 - v1) * (S(y, Ly * 0.3, L) - S(y, Ly * 0.7, L)) + dBx1 + dBx2 | ||
|
||
def bz(x, y): | ||
return 0.0 | ||
|
||
def b2(x, y): | ||
return bx(x, y) ** 2 + by(x, y) ** 2 + bz(x, y) ** 2 | ||
|
||
def T(x, y): | ||
K = 0.7 | ||
temp = 1.0 / density(x, y) * (K - b2(x, y) * 0.5) | ||
assert np.all(temp > 0) | ||
return temp | ||
|
||
def vxyz(x, y): | ||
return 0.0 | ||
|
||
def vthxyz(x, y): | ||
return np.sqrt(T(x, y)) | ||
|
||
vvv = {**{f"vbulk{c}": vxyz for c in "xyz"}, **{f"vth{c}": vthxyz for c in "xyz"}} | ||
|
||
ph.MaxwellianFluidModel( | ||
bx=bx, by=by, bz=bz, protons={"charge": 1, "density": density, **vvv} | ||
) | ||
ph.ElectronModel(closure="isothermal", Te=0.0) | ||
|
||
for quantity in ["E", "B"]: | ||
ph.ElectromagDiagnostics(quantity=quantity, write_timestamps=timestamps) | ||
for quantity in ["density", "bulkVelocity"]: | ||
ph.FluidDiagnostics(quantity=quantity, write_timestamps=timestamps) | ||
|
||
ph.FluidDiagnostics( | ||
quantity="density", write_timestamps=timestamps, population_name="protons" | ||
) | ||
ph.InfoDiagnostics(quantity="particle_count") | ||
|
||
if LOAD_BALANCE: | ||
ph.LoadBalancer(active=True, auto=True, mode="nppc", tol=0.05) | ||
|
@@ -201,8 +130,15 @@ def test_run(self): | |
Simulator(config()).run().reset() | ||
if cpp.mpi_rank() == 0: | ||
plot(diag_dir) | ||
|
||
if SCOPE_TIMING: | ||
m_plotting.plot_run_timer_data(diag_dir, cpp.mpi_rank()) | ||
try: | ||
from tools.python3 import plotting as m_plotting | ||
|
||
m_plotting.plot_run_timer_data(diag_dir, cpp.mpi_rank()) | ||
except ImportError: | ||
print("Phlop not found - install with: `pip install phlop`") | ||
|
||
cpp.mpi_barrier() | ||
return self | ||
|
||
|
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.
Fix unused variable warning.
The
timestamps
variable is assigned but never used. Consider either returning or removing it.📝 Committable suggestion
🧰 Tools
🪛 Ruff (0.8.2)
25-25: Local variable
timestamps
is assigned to but never usedRemove assignment to unused variable
timestamps
(F841)