def setup_sm(sm_name, settings={}): xt, yt, xlimits = get_rans_crm_wing() _tmp = __import__('smt', globals(), locals(), ['surrogate_models'], 0) interp = getattr(_tmp.surrogate_models, sm_name)(**settings) interp.set_training_values(xt, yt) with Silence(): interp.train() return xt, yt, interp
def test_ny(self): xt, yt, _ = get_rans_crm_wing() interp = QP() interp.set_training_values(xt, yt) interp.train() v0 = np.zeros((4, 2)) for ix, i in enumerate([10, 11, 12, 13]): v0[ix, :] = interp.predict_values(np.atleast_2d(xt[i, :])) v1 = interp.predict_values(np.atleast_2d(xt[10:14, :])) expected_diff = np.zeros((4, 2)) np.testing.assert_allclose(v1 - v0, expected_diff, atol=1e-15)
def setupCRM(LF_candidate="QP", Bridge_candidate="KRG", type_bridge="Additive"): xt, yt, _ = get_rans_crm_wing() optionsLF = {} optionsB = {} M = VFM( type_bridge=type_bridge, name_model_LF=LF_candidate, name_model_bridge=Bridge_candidate, X_LF=xt, y_LF=yt, X_HF=xt, y_HF=yt, options_LF=optionsLF, options_bridge=optionsB, ) return M, xt
from smt.surrogate_models import RMTC from smt.examples.rans_crm_wing.rans_crm_wing import ( get_rans_crm_wing, plot_rans_crm_wing, ) xt, yt, xlimits = get_rans_crm_wing() interp = RMTC( num_elements=20, xlimits=xlimits, nonlinear_maxiter=100, energy_weight=1e-10 ) interp.set_training_values(xt, yt) interp.train() plot_rans_crm_wing(xt, yt, xlimits, interp)