# LeastSquaresFit

Performs a polynomial least squares fit on the data contained in another VectorPostprocessor

## Description

LeastSquaresFit is used perform a polynomial least squares fit of data provided through another VectorPostprocessor. It computes the coefficients for a polynomial of arbitrary, user-specified order that minimize the error using a standard least-squares procedure. This object provides the option of either outputting the polynomial coefficients of the least squares fit as a single vector, or outputting a user-defined number of samples from the polynomial using the fitted coefficients.

This VectorPostprocessor is closely related to the LeastSquaresFitHistory VectorPostprocessor, which performs the same type of least squares fit, but stores the results in a set of vectors that store the full history of the individual coefficients over a transient analysis.

The vectors of values of the independent () and dependent () variables on which the least squares fit is performed are provided through another VectorPostprocessor, which must provide two equally-sized vectors of data upon which to operate. The name of this VectorPostprocesor is provided using the vectorpostprocessor parameter, and the names of the data vectors are provided with the x_name and y_name parameters. The vectors of data can be shifted and/or scaled through the use of optional parameters.

The user must define whether the output should be in the form of polynomial coefficients or samples using the output parameter. If the option to output polynommial coefficients is used, they are stored in a vector named coefficients. If samples are requested, the nam es of the sample vectors are the same as those of the data specified by x_name and y_name.

## Input Parameters

• vectorpostprocessorThe vectorpostprocessor on whose values we perform a least squares fit

C++ Type:VectorPostprocessorName

Options:

Description:The vectorpostprocessor on whose values we perform a least squares fit

• y_nameThe name of the dependent variable

C++ Type:std::string

Options:

Description:The name of the dependent variable

• x_nameThe name of the independent variable

C++ Type:std::string

Options:

Description:The name of the independent variable

• orderThe order of the polynomial fit

C++ Type:unsigned int

Options:

Description:The order of the polynomial fit

### Required Parameters

• sample_x_maxThe maximum x value of the of samples to be output

C++ Type:double

Options:

Description:The maximum x value of the of samples to be output

• y_scale1Value used to scale y values (scaling is done after shifting)

Default:1

C++ Type:double

Options:

Description:Value used to scale y values (scaling is done after shifting)

• outputCoefficientsThe quantity to output. Options are: Coefficients Samples

Default:Coefficients

C++ Type:MooseEnum

Options:Coefficients Samples

Description:The quantity to output. Options are: Coefficients Samples

• sample_x_minThe minimum x value of the of samples to be output

C++ Type:double

Options:

Description:The minimum x value of the of samples to be output

• contains_complete_historyFalseSet this flag to indicate that the values in all vectors declared by this VPP represent a time history (e.g. with each invocation, new values are added and old values are never removed). This changes the output so that only a single file is output and updated with each invocation

Default:False

C++ Type:bool

Options:

Description:Set this flag to indicate that the values in all vectors declared by this VPP represent a time history (e.g. with each invocation, new values are added and old values are never removed). This changes the output so that only a single file is output and updated with each invocation

• num_samplesThe number of samples to be output

C++ Type:unsigned int

Options:

Description:The number of samples to be output

• execute_onTIMESTEP_ENDThe list of flag(s) indicating when this object should be executed, the available options include NONE, INITIAL, LINEAR, NONLINEAR, TIMESTEP_END, TIMESTEP_BEGIN, FINAL, CUSTOM.

Default:TIMESTEP_END

C++ Type:ExecFlagEnum

Options:NONE INITIAL LINEAR NONLINEAR TIMESTEP_END TIMESTEP_BEGIN FINAL CUSTOM

Description:The list of flag(s) indicating when this object should be executed, the available options include NONE, INITIAL, LINEAR, NONLINEAR, TIMESTEP_END, TIMESTEP_BEGIN, FINAL, CUSTOM.

• x_shift0Value used to shift x values (shifting is done before scaling)

Default:0

C++ Type:double

Options:

Description:Value used to shift x values (shifting is done before scaling)

• y_shift0Value used to shift y values (shifting is done before scaling)

Default:0

C++ Type:double

Options:

Description:Value used to shift y values (shifting is done before scaling)

• x_scale1Value used to scale x values (scaling is done after shifting)

Default:1

C++ Type:double

Options:

Description:Value used to scale x values (scaling is done after shifting)

### Optional Parameters

• enableTrueSet the enabled status of the MooseObject.

Default:True

C++ Type:bool

Options:

Description:Set the enabled status of the MooseObject.

• use_displaced_meshFalseWhether or not this object should use the displaced mesh for computation. Note that in the case this is true but no displacements are provided in the Mesh block the undisplaced mesh will still be used.

Default:False

C++ Type:bool

Options:

Description:Whether or not this object should use the displaced mesh for computation. Note that in the case this is true but no displacements are provided in the Mesh block the undisplaced mesh will still be used.

• outputsVector of output names were you would like to restrict the output of variables(s) associated with this object

C++ Type:std::vector

Options:

Description:Vector of output names were you would like to restrict the output of variables(s) associated with this object

• control_tagsAdds user-defined labels for accessing object parameters via control logic.

C++ Type:std::vector

Options:

Description:Adds user-defined labels for accessing object parameters via control logic.

• allow_duplicate_execution_on_initialFalseIn the case where this UserObject is depended upon by an initial condition, allow it to be executed twice during the initial setup (once before the IC and again after mesh adaptivity (if applicable).

Default:False

C++ Type:bool

Options:

Description:In the case where this UserObject is depended upon by an initial condition, allow it to be executed twice during the initial setup (once before the IC and again after mesh adaptivity (if applicable).

• force_preauxFalseForces the GeneralUserObject to be executed in PREAUX

Default:False

C++ Type:bool

Options:

Description:Forces the GeneralUserObject to be executed in PREAUX