Skip to content

Setup a model from scratch

canrong qiu edited this page May 22, 2021 · 1 revision

To set up a model, you need a data file of specific format (refer to Data format section before), model script, and fit parameters. You should define the fit parameters inside the model script. Play with those examples below to get yourself being more familiar with model setup. To run your model script well, you need two minimum components in your script. First is the definitions of fit parameters, and second is a function named Sim at the end of the script. This Sim function is mandatory. It takes the first argument of data, which is a list of dataset instance. The body of Sim function is the place where you implement the calculation of the y variable (eg. structure factor for CTR model) you want to fit. This function should return a three-member tuple. The 1st tuple member is a list of y variable values calculated from the model, 2nd tuple member is a penalty factor, which should be set to 1 if you don’t have any penalty function of place a constraint. The last tuple member is a list of weighting factors scaled to the calculated FOM value for each dataset. You can assign different weighting factos for different datasets during fit. This way, the fit subroutine will bias towards making better fit to the dataset with larger weighting factor. You can simply set the scaling factor to 1 for each dataset to disable the weighting strategy. We will talk about some API functions for CTR structure factor calculations that are implemented in SuPerRod.

Clone this wiki locally