From a413d7f1a95e9e3914ee2e2b35a40b2af68500bc Mon Sep 17 00:00:00 2001 From: Benjamin Rodenberg Date: Mon, 15 Jan 2024 12:44:38 +0100 Subject: [PATCH 1/5] Remove unnecessary statements. Move time step to a better place. --- partitioned-heat-conduction/nutils/heat.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/partitioned-heat-conduction/nutils/heat.py b/partitioned-heat-conduction/nutils/heat.py index edea5b5be..1b56407d9 100644 --- a/partitioned-heat-conduction/nutils/heat.py +++ b/partitioned-heat-conduction/nutils/heat.py @@ -128,17 +128,17 @@ def main(side='Dirichlet', n=10, degree=1, timestep=.1, alpha=3., beta=1.2): if not participant.is_coupling_ongoing(): break - # read data from participant - readdata = precice_read(dt) - # save checkpoint if participant.requires_writing_checkpoint(): checkpoint = lhs, t, istep # prepare next timestep + precice_dt = participant.get_max_time_step_size() + dt = min(timestep, precice_dt) lhs0 = lhs istep += 1 - dt = min(timestep, precice_dt) + # read data from participant + readdata = precice_read(dt) t += dt # update (time-dependent) boundary condition @@ -168,8 +168,6 @@ def main(side='Dirichlet', n=10, degree=1, timestep=.1, alpha=3., beta=1.2): # do the coupling participant.advance(dt) - precice_dt = participant.get_max_time_step_size() - dt = min(timestep, precice_dt) # read checkpoint if required if participant.requires_reading_checkpoint(): From 7b34e0a9f8098ad581e244e83b69a7b5db8e7ee1 Mon Sep 17 00:00:00 2001 From: Benjamin Rodenberg Date: Mon, 15 Jan 2024 13:01:49 +0100 Subject: [PATCH 2/5] More rearranging. --- flow-over-heated-plate/solid-nutils/solid.py | 4 +--- partitioned-heat-conduction/nutils/heat.py | 2 -- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/flow-over-heated-plate/solid-nutils/solid.py b/flow-over-heated-plate/solid-nutils/solid.py index c417cc46c..75a10d513 100644 --- a/flow-over-heated-plate/solid-nutils/solid.py +++ b/flow-over-heated-plate/solid-nutils/solid.py @@ -55,8 +55,6 @@ def fluxdofs(v): return projection_matrix.solve(v, constrain=projection_cons) dt = 0.01 participant.initialize() - precice_dt = participant.get_max_time_step_size() - dt = min(dt, precice_dt) # set u = uwall as initial condition and visualize sqr = domain.integral('(u - uwall)^2' @ ns, degree=2) @@ -81,6 +79,7 @@ def fluxdofs(v): return projection_matrix.solve(v, constrain=projection_cons) timestep_checkpoint = timestep # potentially adjust non-matching timestep sizes + precice_dt = participant.get_max_time_step_size() dt = min(dt, precice_dt) # solve nutils timestep @@ -93,7 +92,6 @@ def fluxdofs(v): return projection_matrix.solve(v, constrain=projection_cons) # do the coupling participant.advance(dt) - precice_dt = participant.get_max_time_step_size() # advance variables timestep += 1 diff --git a/partitioned-heat-conduction/nutils/heat.py b/partitioned-heat-conduction/nutils/heat.py index 1b56407d9..968a40926 100644 --- a/partitioned-heat-conduction/nutils/heat.py +++ b/partitioned-heat-conduction/nutils/heat.py @@ -100,8 +100,6 @@ def main(side='Dirichlet', n=10, degree=1, timestep=.1, alpha=3., beta=1.2): precice_write(coupling_sample.eval(0.)) participant.initialize() - precice_dt = participant.get_max_time_step_size() - dt = min(timestep, precice_dt) t = 0. istep = 0 From b0d71a8aed2270cfcd096662eec360186fb12574 Mon Sep 17 00:00:00 2001 From: Benjamin Rodenberg Date: Wed, 17 Jan 2024 17:11:08 +0100 Subject: [PATCH 3/5] Use requirements.txt and create venv in run.sh. --- channel-transport/fluid-nutils/requirements.txt | 2 ++ channel-transport/fluid-nutils/run.sh | 3 +++ flow-over-heated-plate/solid-nutils/requirements.txt | 2 ++ flow-over-heated-plate/solid-nutils/run.sh | 4 +++- partitioned-heat-conduction-direct/nutils/requirements.txt | 2 ++ partitioned-heat-conduction-direct/nutils/run.sh | 4 ++++ partitioned-heat-conduction/nutils/requirements.txt | 2 ++ partitioned-heat-conduction/nutils/run.sh | 4 ++++ perpendicular-flap/fluid-nutils/requirements.txt | 2 ++ perpendicular-flap/fluid-nutils/run.sh | 3 +++ perpendicular-flap/solid-nutils/requirements.txt | 2 ++ perpendicular-flap/solid-nutils/run.sh | 3 +++ two-scale-heat-conduction/macro-nutils/requirements.txt | 2 ++ two-scale-heat-conduction/macro-nutils/run.sh | 3 +++ two-scale-heat-conduction/micro-nutils/requirements.txt | 2 ++ two-scale-heat-conduction/micro-nutils/run.sh | 4 ++++ 16 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 channel-transport/fluid-nutils/requirements.txt create mode 100644 flow-over-heated-plate/solid-nutils/requirements.txt create mode 100644 partitioned-heat-conduction-direct/nutils/requirements.txt create mode 100644 partitioned-heat-conduction/nutils/requirements.txt create mode 100644 perpendicular-flap/fluid-nutils/requirements.txt create mode 100644 perpendicular-flap/solid-nutils/requirements.txt create mode 100644 two-scale-heat-conduction/macro-nutils/requirements.txt create mode 100644 two-scale-heat-conduction/micro-nutils/requirements.txt diff --git a/channel-transport/fluid-nutils/requirements.txt b/channel-transport/fluid-nutils/requirements.txt new file mode 100644 index 000000000..44fdad3d4 --- /dev/null +++ b/channel-transport/fluid-nutils/requirements.txt @@ -0,0 +1,2 @@ +nutils==7 +pyprecice==3.0.0.0dev2 \ No newline at end of file diff --git a/channel-transport/fluid-nutils/run.sh b/channel-transport/fluid-nutils/run.sh index 788f40d13..00b103a23 100755 --- a/channel-transport/fluid-nutils/run.sh +++ b/channel-transport/fluid-nutils/run.sh @@ -1,4 +1,7 @@ #!/bin/sh set -e -u +python3 -m venv .venv +. .venv/bin/activate +pip install -r requirements.txt python3 fluid.py diff --git a/flow-over-heated-plate/solid-nutils/requirements.txt b/flow-over-heated-plate/solid-nutils/requirements.txt new file mode 100644 index 000000000..44fdad3d4 --- /dev/null +++ b/flow-over-heated-plate/solid-nutils/requirements.txt @@ -0,0 +1,2 @@ +nutils==7 +pyprecice==3.0.0.0dev2 \ No newline at end of file diff --git a/flow-over-heated-plate/solid-nutils/run.sh b/flow-over-heated-plate/solid-nutils/run.sh index 21bd5c3b1..8678a56d1 100755 --- a/flow-over-heated-plate/solid-nutils/run.sh +++ b/flow-over-heated-plate/solid-nutils/run.sh @@ -1,5 +1,7 @@ #!/bin/bash set -e -u +python3 -m venv .venv +. .venv/bin/activate +pip install -r requirements.txt python3 solid.py - diff --git a/partitioned-heat-conduction-direct/nutils/requirements.txt b/partitioned-heat-conduction-direct/nutils/requirements.txt new file mode 100644 index 000000000..44fdad3d4 --- /dev/null +++ b/partitioned-heat-conduction-direct/nutils/requirements.txt @@ -0,0 +1,2 @@ +nutils==7 +pyprecice==3.0.0.0dev2 \ No newline at end of file diff --git a/partitioned-heat-conduction-direct/nutils/run.sh b/partitioned-heat-conduction-direct/nutils/run.sh index 4b531fe9c..9c146a51c 100755 --- a/partitioned-heat-conduction-direct/nutils/run.sh +++ b/partitioned-heat-conduction-direct/nutils/run.sh @@ -8,6 +8,10 @@ if [ -z "$*" ] ; then usage fi +python3 -m venv .venv +. .venv/bin/activate +pip install -r requirements.txt + while getopts ":dn" opt; do case ${opt} in d) diff --git a/partitioned-heat-conduction/nutils/requirements.txt b/partitioned-heat-conduction/nutils/requirements.txt new file mode 100644 index 000000000..44fdad3d4 --- /dev/null +++ b/partitioned-heat-conduction/nutils/requirements.txt @@ -0,0 +1,2 @@ +nutils==7 +pyprecice==3.0.0.0dev2 \ No newline at end of file diff --git a/partitioned-heat-conduction/nutils/run.sh b/partitioned-heat-conduction/nutils/run.sh index 60e3f3911..21341a572 100755 --- a/partitioned-heat-conduction/nutils/run.sh +++ b/partitioned-heat-conduction/nutils/run.sh @@ -8,6 +8,10 @@ if [ -z "$*" ] ; then usage fi +python3 -m venv .venv +. .venv/bin/activate +pip install -r requirements.txt + while getopts ":dn" opt; do case ${opt} in d) diff --git a/perpendicular-flap/fluid-nutils/requirements.txt b/perpendicular-flap/fluid-nutils/requirements.txt new file mode 100644 index 000000000..c314303e3 --- /dev/null +++ b/perpendicular-flap/fluid-nutils/requirements.txt @@ -0,0 +1,2 @@ +nutils==6 +pyprecice==3.0.0.0dev2 \ No newline at end of file diff --git a/perpendicular-flap/fluid-nutils/run.sh b/perpendicular-flap/fluid-nutils/run.sh index 788f40d13..00b103a23 100755 --- a/perpendicular-flap/fluid-nutils/run.sh +++ b/perpendicular-flap/fluid-nutils/run.sh @@ -1,4 +1,7 @@ #!/bin/sh set -e -u +python3 -m venv .venv +. .venv/bin/activate +pip install -r requirements.txt python3 fluid.py diff --git a/perpendicular-flap/solid-nutils/requirements.txt b/perpendicular-flap/solid-nutils/requirements.txt new file mode 100644 index 000000000..a0a368d7b --- /dev/null +++ b/perpendicular-flap/solid-nutils/requirements.txt @@ -0,0 +1,2 @@ +nutils +pyprecice==3.0.0.0dev2 \ No newline at end of file diff --git a/perpendicular-flap/solid-nutils/run.sh b/perpendicular-flap/solid-nutils/run.sh index 2f48dbf3c..b57faa9f2 100755 --- a/perpendicular-flap/solid-nutils/run.sh +++ b/perpendicular-flap/solid-nutils/run.sh @@ -1,4 +1,7 @@ #!/bin/sh set -e -u +python3 -m venv .venv +. .venv/bin/activate +pip install -r requirements.txt python3 solid.py richoutput=no diff --git a/two-scale-heat-conduction/macro-nutils/requirements.txt b/two-scale-heat-conduction/macro-nutils/requirements.txt new file mode 100644 index 000000000..44fdad3d4 --- /dev/null +++ b/two-scale-heat-conduction/macro-nutils/requirements.txt @@ -0,0 +1,2 @@ +nutils==7 +pyprecice==3.0.0.0dev2 \ No newline at end of file diff --git a/two-scale-heat-conduction/macro-nutils/run.sh b/two-scale-heat-conduction/macro-nutils/run.sh index b646e5ab0..3162a1900 100755 --- a/two-scale-heat-conduction/macro-nutils/run.sh +++ b/two-scale-heat-conduction/macro-nutils/run.sh @@ -1,4 +1,7 @@ #!/bin/sh set -e -u +python3 -m venv .venv +. .venv/bin/activate +pip install -r requirements.txt NUTILS_RICHOUTPUT=no python3 macro.py diff --git a/two-scale-heat-conduction/micro-nutils/requirements.txt b/two-scale-heat-conduction/micro-nutils/requirements.txt new file mode 100644 index 000000000..44fdad3d4 --- /dev/null +++ b/two-scale-heat-conduction/micro-nutils/requirements.txt @@ -0,0 +1,2 @@ +nutils==7 +pyprecice==3.0.0.0dev2 \ No newline at end of file diff --git a/two-scale-heat-conduction/micro-nutils/run.sh b/two-scale-heat-conduction/micro-nutils/run.sh index bff79b7f4..8edbe9445 100755 --- a/two-scale-heat-conduction/micro-nutils/run.sh +++ b/two-scale-heat-conduction/micro-nutils/run.sh @@ -3,6 +3,10 @@ set -e -u usage() { echo "Usage: cmd [-s] [-p n]" 1>&2; exit 1; } +python3 -m venv .venv +. .venv/bin/activate +pip install -r requirements.txt + # Check if no input argument was provided if [ -z "$*" ] ; then echo "No input argument provided. Micro Manager is launched in serial" From 711ac905261f12960d220fc68f5f684bec61059b Mon Sep 17 00:00:00 2001 From: Benjamin Rodenberg Date: Wed, 17 Jan 2024 17:32:43 +0100 Subject: [PATCH 4/5] Revert readability changes. Moved to #443. --- flow-over-heated-plate/solid-nutils/solid.py | 4 +++- partitioned-heat-conduction/nutils/heat.py | 12 ++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/flow-over-heated-plate/solid-nutils/solid.py b/flow-over-heated-plate/solid-nutils/solid.py index 75a10d513..c417cc46c 100644 --- a/flow-over-heated-plate/solid-nutils/solid.py +++ b/flow-over-heated-plate/solid-nutils/solid.py @@ -55,6 +55,8 @@ def fluxdofs(v): return projection_matrix.solve(v, constrain=projection_cons) dt = 0.01 participant.initialize() + precice_dt = participant.get_max_time_step_size() + dt = min(dt, precice_dt) # set u = uwall as initial condition and visualize sqr = domain.integral('(u - uwall)^2' @ ns, degree=2) @@ -79,7 +81,6 @@ def fluxdofs(v): return projection_matrix.solve(v, constrain=projection_cons) timestep_checkpoint = timestep # potentially adjust non-matching timestep sizes - precice_dt = participant.get_max_time_step_size() dt = min(dt, precice_dt) # solve nutils timestep @@ -92,6 +93,7 @@ def fluxdofs(v): return projection_matrix.solve(v, constrain=projection_cons) # do the coupling participant.advance(dt) + precice_dt = participant.get_max_time_step_size() # advance variables timestep += 1 diff --git a/partitioned-heat-conduction/nutils/heat.py b/partitioned-heat-conduction/nutils/heat.py index 968a40926..edea5b5be 100644 --- a/partitioned-heat-conduction/nutils/heat.py +++ b/partitioned-heat-conduction/nutils/heat.py @@ -100,6 +100,8 @@ def main(side='Dirichlet', n=10, degree=1, timestep=.1, alpha=3., beta=1.2): precice_write(coupling_sample.eval(0.)) participant.initialize() + precice_dt = participant.get_max_time_step_size() + dt = min(timestep, precice_dt) t = 0. istep = 0 @@ -126,17 +128,17 @@ def main(side='Dirichlet', n=10, degree=1, timestep=.1, alpha=3., beta=1.2): if not participant.is_coupling_ongoing(): break + # read data from participant + readdata = precice_read(dt) + # save checkpoint if participant.requires_writing_checkpoint(): checkpoint = lhs, t, istep # prepare next timestep - precice_dt = participant.get_max_time_step_size() - dt = min(timestep, precice_dt) lhs0 = lhs istep += 1 - # read data from participant - readdata = precice_read(dt) + dt = min(timestep, precice_dt) t += dt # update (time-dependent) boundary condition @@ -166,6 +168,8 @@ def main(side='Dirichlet', n=10, degree=1, timestep=.1, alpha=3., beta=1.2): # do the coupling participant.advance(dt) + precice_dt = participant.get_max_time_step_size() + dt = min(timestep, precice_dt) # read checkpoint if required if participant.requires_reading_checkpoint(): From 0796b87d72b3dce5435903f1ad76642786e39fc9 Mon Sep 17 00:00:00 2001 From: Benjamin Rodenberg Date: Thu, 18 Jan 2024 11:40:48 +0100 Subject: [PATCH 5/5] Update perpendicular-flap/solid-nutils/requirements.txt Co-authored-by: Benjamin Uekermann --- perpendicular-flap/solid-nutils/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/perpendicular-flap/solid-nutils/requirements.txt b/perpendicular-flap/solid-nutils/requirements.txt index a0a368d7b..c96773dfa 100644 --- a/perpendicular-flap/solid-nutils/requirements.txt +++ b/perpendicular-flap/solid-nutils/requirements.txt @@ -1,2 +1,2 @@ -nutils +nutils==8 pyprecice==3.0.0.0dev2 \ No newline at end of file