Skip to content

Commit a8a0e5c

Browse files
committed
Clean-up of python scripts
1 parent 1a1f809 commit a8a0e5c

File tree

2 files changed

+26
-43
lines changed

2 files changed

+26
-43
lines changed

elastic-tube-1d/fluid-python/FluidSolver.py

Lines changed: 25 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,35 @@
66
from thetaScheme import perform_partitioned_implicit_trapezoidal_rule_step, perform_partitioned_implicit_euler_step
77
import numpy as np
88
import tubePlotting
9-
109
import matplotlib.pyplot as plt
1110
import matplotlib.animation as manimation
12-
1311
from output import writeOutputToVTK
14-
1512
import precice
1613
from precice import action_write_initial_data, action_write_iteration_checkpoint, action_read_iteration_checkpoint
1714

15+
# physical properties of the tube
16+
r0 = 1 / np.sqrt(np.pi) # radius of the tube
17+
a0 = r0**2 * np.pi # cross sectional area
18+
u0 = 10 # mean velocity
19+
ampl = 3 # amplitude of varying velocity
20+
frequency = 10 # frequency of variation
21+
t_shift = 0 # temporal shift of variation
22+
p0 = 0 # pressure at outlet
23+
kappa = 100
24+
25+
L = 10 # length of tube/simulation domain
26+
N = 100
27+
dx = L / kappa
28+
# helper function to create constant cross section
29+
30+
def velocity_in(t): return u0 + ampl * np.sin(frequency *
31+
(t + t_shift) * np.pi) # inflow velocity
32+
33+
34+
def crossSection0(N):
35+
return a0 * np.ones(N + 1)
36+
37+
1838
parser = argparse.ArgumentParser()
1939
parser.add_argument("configurationFileName", help="Name of the xml precice configuration file.",
2040
nargs='?', type=str, default="../precice-config.xml")
@@ -44,39 +64,10 @@
4464

4565
print("Starting Fluid Solver...")
4666

47-
configFileName = args.configurationFileName
48-
49-
# physical properties of the tube
50-
r0 = 1 / np.sqrt(np.pi) # radius of the tube
51-
a0 = r0**2 * np.pi # cross sectional area
52-
u0 = 10 # mean velocity
53-
ampl = 3 # amplitude of varying velocity
54-
frequency = 10 # frequency of variation
55-
t_shift = 0 # temporal shift of variation
56-
p0 = 0 # pressure at outlet
57-
kappa = 100
58-
59-
60-
def velocity_in(t): return u0 + ampl * np.sin(frequency *
61-
(t + t_shift) * np.pi) # inflow velocity
62-
63-
64-
L = 10 # length of tube/simulation domain
65-
N = 100
66-
dx = L / kappa
67-
# helper function to create constant cross section
68-
69-
70-
def crossSection0(N):
71-
return a0 * np.ones(N + 1)
72-
73-
7467
print("N: " + str(N))
7568

76-
solverName = "Fluid"
77-
7869
print("Configure preCICE...")
79-
interface = precice.Interface(solverName, configFileName, 0, 1)
70+
interface = precice.Interface("Fluid", args.configurationFileName, 0, 1)
8071
print("preCICE configured...")
8172

8273
dimensions = interface.get_dimensions()
@@ -110,11 +101,10 @@ def crossSection0(N):
110101
vertexIDs = interface.set_mesh_vertices(meshID, grid)
111102

112103
t = 0
113-
precice_dt = 0.01
114104

115105
print("Fluid: init precice...")
116106
# preCICE defines timestep size of solver via precice-config.xml
117-
interface.initialize()
107+
precice_dt = interface.initialize()
118108

119109
if interface.is_action_required(action_write_initial_data()):
120110
interface.write_block_scalar_data(pressureID, vertexIDs, pressure)

elastic-tube-1d/solid-python/SolidSolver.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,9 @@
1717
E = 10000 # elasticity module
1818
c_mk = np.sqrt(E / 2 / r0) # wave speed
1919

20-
2120
def crossSection0(N):
2221
return a0 * np.ones(N + 1)
2322

24-
###############
25-
2623

2724
print("Starting Solid Solver...")
2825

@@ -38,14 +35,10 @@ def crossSection0(N):
3835
print("Try '$ python SolidSolver.py precice-config.xml'")
3936
quit()
4037

41-
configFileName = args.configurationFileName
42-
4338
print("N: " + str(N))
4439

45-
solverName = "Solid"
46-
4740
print("Configure preCICE...")
48-
interface = precice.Interface(solverName, configFileName, 0, 1)
41+
interface = precice.Interface("Solid", args.configurationFileName, 0, 1)
4942
print("preCICE configured...")
5043

5144
dimensions = interface.get_dimensions()

0 commit comments

Comments
 (0)