def test_optimal_mu(self): pod = POD() rbf = RBF() db = Database(param, snapshots.T) rom = ROM(db, pod, rbf).fit() opt_mu = rom.optimal_mu() np.testing.assert_allclose(opt_mu, [[-0.17687147, -0.21820951]], rtol=1e-4)
from ipywidgets import interact def plot_solution(mu0, mu1): new_mu = [mu0, mu1] pred_sol = rom.predict(new_mu) plt.figure(figsize=(8, 7)) plt.triplot(triang, 'b-', lw=0.1) plt.tripcolor(triang, pred_sol) plt.colorbar() interact(plot_solution, mu0=8, mu1=1) # ## Error Approximation & Improvement # # At the moment, we used a database which is composed by 8 files. we would have an idea of the approximation accuracy we are able to reach with these high-fidelity solutions. Using the *leave-one-out* strategy, an error is computed for each parametric point in our database and these values are returned as array. # In[12]: for pt, error in zip(rom.database.parameters, rom.loo_error()): print(pt, error) # Moreover, we can use the information about the errors to locate the parametric points where we have to compute the new high-fidelity solutions and add these to the database in order to optimally improve the accuracy. # In[13]: rom.optimal_mu() # These function can be used to achieve the wanted (estimated) accuracy.