surrogate modeling using gaussian process-凯发k8网页登录
in this example, you replace a hydraulic cavitation cycle model in simulink® with a surrogate nonlinear arx (nlarx) model to facilitate faster simulation.
in the hydraulic cavitation cycle for this example, the fluid in a custom double-acting cylinder can cavitate and recover. during the repeating cycle of oscillating pressure, the absolute pressure does not drop below absolute zero as the bulk modulus of the homogeneous liquid-gas mixture decreases accordingly at low pressures. the input to this system is a velocity source, and the output observed is the absolute pressure in the cylinder chambers.
often, such physical models are computationally expensive to simulate. you can reduce simulation time by replacing the model with a simpler surrogate model. in this example, you create a surrogate model for this physical system an estimated nlarx model with a gaussian process nonlinear output function. using this approach, you can guide the dynamics of the system by choosing how regressors (delayed forms of input-output data) interact with the nonlinear output function.
obtain input-output data
to estimate the model, you must first obtain input-output data by simulating the original model.
open the model and set the amplitude of the velocity input signal.
modelname = 'hydrauliccavitationcyclefullmodel'; velocityamplitude = 0.05; %#ok<*nasgu> open_system(modelname)
model estimation requires an input signal that is rich enough to capture the dynamics of this nonlinear system. therefore, the model applies a pulse train velocity signal to the custom cylinder.
this model includes an iddata sink block, which saves the simulated input-output data to the matlab® workspace as an iddata
object.
simulate the model.
sim(modelname);
plot the data from the saved iddata
object.
plot(cavitationcycleiodata)
here, y1 is the output signal, that is the absolute pressure in the cylinder chambers. u1
is the input velocity applied to the custom cylinder.
this system is sensitive to changes in the input source. you must take this sensitivity into account when you train, validate, and use the nlarx model.
estimate model
next, you estimate an nlarx model using this input-output data. the goal is to reasonably replicate the dynamics of the cavitation cycle.
an important aspect of nlarx estimation is the choice of nonlinear output function. for this example, you use a gaussian process output function. the versatility in kernel function provided by this output function allows for variability in model structure.
create a gaussian process mapping object with default settings.
gpobject = idgaussianprocess;
create a regressor set for the nlarx model.
vars = {'y1','u1'}; lags = {1:30,1:60}; regressors = linearregressor(vars,lags);
estimate a nlarx model using the gaussian process output function and the defined linear regressors.
trainedmodel = nlarx(cavitationcycleiodata,regressors,gpobject)
trainedmodel = nonlinear arx model with 1 output and 1 input inputs: u1 outputs: y1 regressors: linear regressors in variables y1, u1 output function: gaussian process function using a squaredexponential kernel sample time: 0.01 seconds status: estimated using nlarx on time domain data "cavitationcycleiodata". fit to estimation data: 99.96% (prediction focus) fpe: 1.586e-08, mse: 1.223e-08 more information in model's "report" property.
validate model
to check the performance of the trained model, first obtain validation data from the original simulink model. for this example, increase the velocity amplitude by 4% and simulate the model.
velocityamplitude = 1.04*0.05; sim(modelname);
compare the output of the trained model to the simulation output using the validation data.
compare(cavitationcycleiodata,trainedmodel)
the model fit for the validation data is over 95%, which indicates that the trained model reasonably represents the dynamics of the system.
test model sensitivity
the performance of the trained model is sensitive to the amplitude of the velocity input. to demonstrate this sensitivity, simulate the trained system with a larger velocity amplitude.
velocityamplitude = 1.1*0.05; sim(modelname);
compare the performance of the trained model to the simulation using this testing data.
compare(cavitationcycleiodata,trainedmodel)
for this data, the fit for the trained model is below 90% and the output pressure differs significantly, particularly for lower pressure values.
given the sensitivity of the trained model, you can consider training another surrogate model for larger amplitude operating conditions while retaining the existing regressor configuration with sufficiently good fit. doing so demonstrates the flexibility of this modeling approach.
substitute surrogate model
to substitute the surrogate system into the simulink model, use a nonlinear arx model block. as an example, open the gpsurrogatemodel
simulink model.
surrogatemodelname = 'gpsurrogatemodel';
open_system(surrogatemodelname)
simulate the surrogate model using the same velocity amplitude as the original estimation data.
velocityamplitude = 0.05; gpsurrogatemodeldata = sim(surrogatemodelname);
simulate the original model using the same velocity amplitude.
sim(modelname);
plot the simulation output and compare it with the estimation data output.
plot(gpsurrogatemodeldata.tout,gpsurrogatemodeldata.simout, ... cavitationcycleiodata.samplinginstants,cavitationcycleiodata.outputdata); title('surrogate model performance - estimation data') xlabel('time (s)') ylabel('absolute pressure (atm)') legend('surrogate model','original model')
see also
functions
- |
blocks
- |