# ResponseSurface¶

Surrogate Model based on second order response surface equations.

Here is a simple example where the ResponseSurface surrogate is used to approximate the output of a sinusoidal component.

import numpy as np

import openmdao.api as om

prob = om.Problem()

sin_mm = om.MetaModelUnStructuredComp()

prob.setup()

# train the surrogate and check predicted value
sin_mm.options['train_x'] = np.linspace(0, 3.14, 20)
sin_mm.options['train_f_x'] = .5*np.sin(sin_mm.options['train_x'])

prob.set_val('sin_mm.x', 2.1)

prob.run_model()

print(prob.get_val('sin_mm.f_x'))

[0.43075734]

/usr/share/miniconda/envs/test/lib/python3.10/site-packages/openmdao/surrogate_models/response_surface.py:78: FutureWarning: rcond parameter will change to the default of machine precision times max(M, N) where M and N are the input matrix dimensions.
To use the future default and silence this warning we advise to pass rcond=None, to keep using the old, explicitly pass rcond=-1.
self.betas, rs, r, s = lstsq(X, y)