Spaces:
Sleeping
Sleeping
Lennard Schober
commited on
Commit
·
cf269e0
1
Parent(s):
d7ccd1d
Tweak some params
Browse files
app.py
CHANGED
@@ -284,8 +284,8 @@ def train_coefficients(m, method, quality, rand_or_det):
|
|
284 |
else:
|
285 |
theta = np.column_stack(
|
286 |
(
|
287 |
-
np.linspace(-
|
288 |
-
np.linspace(-
|
289 |
)
|
290 |
)
|
291 |
|
@@ -304,26 +304,26 @@ def train_coefficients(m, method, quality, rand_or_det):
|
|
304 |
theta=theta,
|
305 |
)
|
306 |
|
307 |
-
#
|
308 |
-
#
|
309 |
-
|
310 |
-
|
|
|
|
|
311 |
# Compute the real solution over the grid
|
312 |
-
|
313 |
-
|
314 |
-
# print(U_real)
|
315 |
# Compute the selected approximation
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
# U_approx[j, i] = np.dot(Phi_at_x_t, alpha)
|
321 |
|
322 |
# Compute average error
|
323 |
-
|
324 |
|
325 |
return (
|
326 |
-
f"Training completed in {end_time} seconds.
|
327 |
)
|
328 |
|
329 |
|
|
|
284 |
else:
|
285 |
theta = np.column_stack(
|
286 |
(
|
287 |
+
np.linspace(-5, 5, m), # Linear spacing for x
|
288 |
+
np.linspace(-25, 25, m), # Linear spacing for y
|
289 |
)
|
290 |
)
|
291 |
|
|
|
304 |
theta=theta,
|
305 |
)
|
306 |
|
307 |
+
# Compute the average error
|
308 |
+
#
|
309 |
+
x = np.linspace(0, 1, n_x) # Spatial grid
|
310 |
+
t = np.linspace(0, 5, n_t) # Temporal grid
|
311 |
+
X, T = np.meshgrid(x, t)
|
312 |
+
|
313 |
# Compute the real solution over the grid
|
314 |
+
U_real = complex_heat_eq_solution(X, T, glob_k, glob_a, glob_b, glob_c)
|
315 |
+
|
|
|
316 |
# Compute the selected approximation
|
317 |
+
U_approx = np.zeros_like(U_real)
|
318 |
+
for i, t_val in enumerate(t):
|
319 |
+
Phi_at_t = Phi[i * n_x : (i + 1) * n_x]
|
320 |
+
U_approx[i, :] = np.dot(Phi_at_t, alpha)
|
|
|
321 |
|
322 |
# Compute average error
|
323 |
+
avg_err = np.mean(np.abs(U_real - U_approx))
|
324 |
|
325 |
return (
|
326 |
+
f"Training completed in {end_time} seconds. The average error is {avg_err}."
|
327 |
)
|
328 |
|
329 |
|