# Curve Fitting using the Optimization Module in COMSOL

## Presentation on theme: "Curve Fitting using the Optimization Module in COMSOL"— Presentation transcript:

Curve Fitting using the Optimization Module in COMSOL

It is often desirable to fit a material model curve to a set of experimental data
For example: The hyperelastic Mooney-Rivlin material model implemented in COMSOL requires, as input, C01 and C10, which must be determined from experimental data Strain, ε Stress, P 0.075 4.90E+05 0.103 8.67E+05 0.15 1.36E+06 0.174 1.55E+06 0.2004 1.71E+06 0.25 1.95E+06 0.305 2.10E+06 0.351 2.17E+06 0.37 2.21E+06

Select Space Dimension as 1D Click Next

Add Physics Select Mathematics > Optimization and Sensitivity > Optimization (opt) and click on the Next icon Next icon

Select Study Type Select Stationary Click the Finish flag after selecting the study type The next slide shows how the COMSOL Desktop should look like after clicking the Finish icon

COMSOL 1D Graphical User Interface

Define the data set Model 1 > Definitions > Functions > Interpolation We can either type in these values in the table or upload from a text file

Create a geometric interval
Model 1 > Geometry 1 > Interval The coordinates specified for the endpoints should be the numbers corresponding to the first and last values in the left column of the data set. Go back to the previous slide and verify that the first value was 0 and the last value was 0.37.

Define an integration coupling operator on Domain 1 (the specified interval)
Model 1 > Definitions > Model Couplings > Integration

Create these variables
Name Expression L 1+x[1/m] P 2*(L-1/L^2)*(C10+C01/L) SquaredDiff intop1((RawData(x[1/m])-P)^2) C01 and C10 are not yet defined, these are the variables to be optimized for later. For now, we just need to define the expression, P, across the entire domain. The tabular data “RawData” is a function of position, x The subdomain expression “P” is an explicit function of x

Create these variables
Model 1 > Definitions > Variables

Set the Objective Function
Model 1 > Optimization (opt) > Global Objective

Specify the variables to be optimized
Model 1 > Optimization (opt) > Global Control Variables

Mesh Model 1 > Mesh 1 > Edge
Select Mesh 1 > Size and choose Extremely Fine

Study steps Right-click on Study 1 and select Show Default Solver
Expand the Solver Configurations branch as shown below

Introduce the optimization solver
Right-click on Study 1 > Solver Configurations > Solver 1 and select Solver Settings > Optimization Solver Right-click on Study 1 > Solver Configurations > Solver 1 > Stationary Solver 1 and select Disable The study step should now look as shown below

Setup the optimization solver
Right-click on Study 1 > Solver Configurations > Solver 1 > Optimization Solver and select Stationary Right-click on Study 1 and select Compute

Results – Optimized Variables
Expand Results > Derived Values Click on the Global control variable C01 branch and click on the Evaluate icon in the Settings window. Repeat the same steps to evaluate the other global control variable C10

Results – Line Graph 1 Right-click on Results and select 1D Plot Group
Right-click on Results > 1D Plot Group 1 and select Line Graph Assign the line interval (Domain 1) to the Selection section in the Line Graph settings In the corresponding Settings Window, use the expression RawData(x) for y-Axis Data

Results – Line Graph 2 Right-click on Results > 1D Plot Group 1 > Line Graph 1 and select Duplicate In the Settings Window, type P for y-Axis Data expression

Results – Raw Data vs. Fit

Summary This tutorial showed how to use the Optimization Module of COMSOL to obtain curve fitting parameters. The specific example shown here could be useful for Structural Mechanics modeling using hyperelastic materials. The concept demonstrated here can always be extended to multivariate optimization as long as a suitable objective function is available.