Lennard Schober commited on
Commit
cf269e0
·
1 Parent(s): d7ccd1d

Tweak some params

Browse files
Files changed (1) hide show
  1. app.py +16 -16
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(-0.5, 0.5, m), # Nonlinear spacing for x
288
- np.linspace(-2.5, 2.5, m), # Nonlinear spacing for y
289
  )
290
  )
291
 
@@ -304,26 +304,26 @@ def train_coefficients(m, method, quality, rand_or_det):
304
  theta=theta,
305
  )
306
 
307
- # Create grids for x and t
308
- # x_random = np.random.uniform(0, 1, 10 * n_x) # Spatial grid
309
- # t_random = np.random.uniform(0, 5, 10 * n_t) # Temporal grid
310
- # X, T = np.meshgrid(x_random, t_random) # Create the mesh grid
 
 
311
  # Compute the real solution over the grid
312
- # U_real = complex_heat_eq_solution(X, T, glob_k, glob_a, glob_b, glob_c)
313
- # print(U_real.shape)
314
- # print(U_real)
315
  # Compute the selected approximation
316
- # U_approx = np.zeros_like(U_real)
317
- # for i, xpos in enumerate(x_random):
318
- # for j, tpos in enumerate(t_random):
319
- # Phi_at_x_t = test_approx([xpos, tpos], theta, method)
320
- # U_approx[j, i] = np.dot(Phi_at_x_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
 
 
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