|
25 | 25 | material_mt = f.read_meshtags(mesh, "materials")
|
26 | 26 |
|
27 | 27 | # TODO Give meaningful volume and boundary names
|
28 |
| -volume_ids = {"volume_0": 0, |
29 |
| - "volume_1": 1, |
30 |
| - "volume_2": 2, |
31 |
| - "volume_3": 3, |
32 |
| - "volume_4": 4} |
| 28 | +volume_ids = {"volume_0": 0, "volume_1": 1, "volume_2": 2, "volume_3": 3, "volume_4": 4} |
33 | 29 | boundary_ids = {}
|
34 |
| -boundary_ids["T"] = {"boundary_0": 0, |
35 |
| - "boundary_1": 1, |
36 |
| - "boundary_2": 2, |
37 |
| - "boundary_3": 3} |
38 |
| -boundary_ids["u"] = {"boundary_0": 0, |
39 |
| - "boundary_1": 1, |
40 |
| - "boundary_2": 2} |
| 30 | +boundary_ids["T"] = {"boundary_0": 0, "boundary_1": 1, "boundary_2": 2, "boundary_3": 3} |
| 31 | +boundary_ids["u"] = {"boundary_0": 0, "boundary_1": 1, "boundary_2": 2} |
41 | 32 |
|
42 | 33 | # Add materials
|
43 |
| -materials = {volume_ids["volume_0"]: mat_dict["Copper"], |
44 |
| - volume_ids["volume_1"]: mat_dict["CuCrZr"], |
45 |
| - volume_ids["volume_2"]: mat_dict["304SS"], |
46 |
| - volume_ids["volume_3"]: mat_dict["304SS"], |
47 |
| - volume_ids["volume_4"]: mat_dict["304SS"]} |
| 34 | +materials = { |
| 35 | + volume_ids["volume_0"]: mat_dict["Copper"], |
| 36 | + volume_ids["volume_1"]: mat_dict["CuCrZr"], |
| 37 | + volume_ids["volume_2"]: mat_dict["304SS"], |
| 38 | + volume_ids["volume_3"]: mat_dict["304SS"], |
| 39 | + volume_ids["volume_4"]: mat_dict["304SS"], |
| 40 | +} |
48 | 41 |
|
49 | 42 |
|
50 | 43 | # Boundary conditions
|
51 | 44 | bcs = {}
|
52 |
| -bcs["T"] = {boundary_ids["T"]["boundary_0"]: |
53 |
| - {"type": "convection", |
54 |
| - "value": lambda x: 293.15 * np.ones_like(x[0]), |
55 |
| - "h": lambda T: 5}, |
56 |
| - boundary_ids["T"]["boundary_1"]: |
57 |
| - {"type": "heat_flux", |
58 |
| - "value": lambda x: 1.6e5 * np.ones_like(x[0])}, |
59 |
| - boundary_ids["T"]["boundary_2"]: |
60 |
| - {"type": "heat_flux", |
61 |
| - "value": lambda x: 5e5 * np.ones_like(x[0])}, |
62 |
| - boundary_ids["T"]["boundary_3"]: |
63 |
| - {"type": "convection", |
64 |
| - "value": lambda x: 293.15 * np.ones_like(x[0]), |
65 |
| - "h": mat_dict["water"]["h"]}} |
66 |
| -bcs["u"] = {boundary_ids["u"]["boundary_0"]: |
67 |
| - {"type": "displacement", |
68 |
| - "value": np.array([0, 0, 0], dtype=PETSc.ScalarType)}, |
69 |
| - boundary_ids["u"]["boundary_1"]: |
70 |
| - {"type": "displacement", |
71 |
| - "value": np.array([0, 0, 0], dtype=PETSc.ScalarType)}, |
72 |
| - boundary_ids["u"]["boundary_2"]: |
73 |
| - {"type": "pressure", |
74 |
| - "value": fem.Constant(mesh, PETSc.ScalarType(-1e3))}} |
| 45 | +bcs["T"] = { |
| 46 | + boundary_ids["T"]["boundary_0"]: { |
| 47 | + "type": "convection", |
| 48 | + "value": lambda x: 293.15 * np.ones_like(x[0]), |
| 49 | + "h": lambda T: 5, |
| 50 | + }, |
| 51 | + boundary_ids["T"]["boundary_1"]: { |
| 52 | + "type": "heat_flux", |
| 53 | + "value": lambda x: 1.6e5 * np.ones_like(x[0]), |
| 54 | + }, |
| 55 | + boundary_ids["T"]["boundary_2"]: { |
| 56 | + "type": "heat_flux", |
| 57 | + "value": lambda x: 5e5 * np.ones_like(x[0]), |
| 58 | + }, |
| 59 | + boundary_ids["T"]["boundary_3"]: { |
| 60 | + "type": "convection", |
| 61 | + "value": lambda x: 293.15 * np.ones_like(x[0]), |
| 62 | + "h": mat_dict["water"]["h"], |
| 63 | + }, |
| 64 | +} |
| 65 | +bcs["u"] = { |
| 66 | + boundary_ids["u"]["boundary_0"]: { |
| 67 | + "type": "displacement", |
| 68 | + "value": np.array([0, 0, 0], dtype=PETSc.ScalarType), |
| 69 | + }, |
| 70 | + boundary_ids["u"]["boundary_1"]: { |
| 71 | + "type": "displacement", |
| 72 | + "value": np.array([0, 0, 0], dtype=PETSc.ScalarType), |
| 73 | + }, |
| 74 | + boundary_ids["u"]["boundary_2"]: { |
| 75 | + "type": "pressure", |
| 76 | + "value": fem.Constant(mesh, PETSc.ScalarType(-1e3)), |
| 77 | + }, |
| 78 | +} |
75 | 79 |
|
76 | 80 | # Elastic source term (not including gravity)
|
77 | 81 | f_u = fem.Constant(mesh, np.array([0, 0, 0], dtype=PETSc.ScalarType))
|
78 | 82 |
|
79 | 83 |
|
80 | 84 | # Thermal source term
|
81 |
| -def f_T(x): return np.zeros_like(x[0]) |
| 85 | +def f_T(x): |
| 86 | + return np.zeros_like(x[0]) |
82 | 87 |
|
83 | 88 |
|
84 | 89 | # Initial temperature
|
85 |
| -def T_0(x): return 293.15 * np.ones_like(x[0]) |
| 90 | +def T_0(x): |
| 91 | + return 293.15 * np.ones_like(x[0]) |
86 | 92 |
|
87 | 93 |
|
88 | 94 | # Acceleration due to gravity
|
89 |
| -g = PETSc.ScalarType(- 9.81) |
| 95 | +g = PETSc.ScalarType(-9.81) |
90 | 96 |
|
91 | 97 | # Solve the problem
|
92 |
| -results = solve(mesh, k, delta_t, num_time_steps, T_0, f_T, |
93 |
| - f_u, g, materials, material_mt, bcs, bc_mt, |
94 |
| - write_to_file=write_to_file, steps_per_write=steps_per_write) |
| 98 | +results = solve( |
| 99 | + mesh, |
| 100 | + k, |
| 101 | + delta_t, |
| 102 | + num_time_steps, |
| 103 | + T_0, |
| 104 | + f_T, |
| 105 | + f_u, |
| 106 | + g, |
| 107 | + materials, |
| 108 | + material_mt, |
| 109 | + bcs, |
| 110 | + bc_mt, |
| 111 | + write_to_file=write_to_file, |
| 112 | + steps_per_write=steps_per_write, |
| 113 | +) |
95 | 114 |
|
96 | 115 | # Write timing and iteration data to file
|
97 | 116 | n_procs = MPI.COMM_WORLD.Get_size()
|
|
0 commit comments