polykin.copolymerization¤
fit_copo_data ¤
fit_copo_data(
data_Ff: list[CopoDataset_Ff] = [],
data_fx: list[CopoDataset_fx] = [],
data_Fx: list[CopoDataset_Fx] = [],
r_guess: tuple[float, float] = (1.0, 1.0),
method: Literal["NLLS", "ODR"] = "NLLS",
alpha: float = 0.05,
plot_data: bool = True,
JCR_linear: bool = True,
JCR_exact: bool = False,
JCR_npoints: int = 200,
JCR_rtol: float = 0.01,
) -> CopoFitResult
Fit copolymer composition data and estimate reactivity ratios.
This function employs rigorous nonlinear algorithms to estimate the reactivity ratios from experimental copolymer composition data of type \(F(f)\), \(f(x;f_0)\), and \(F(x,f_0)\).
The fitting is performed using one of two methods: nonlinear least squares (NLLS) or orthogonal distance regression (ODR). NLLS considers only observational errors in the dependent variable, whereas ODR takes into account observational errors in both the dependent and independent variables. Although the ODR method is statistically more general, it is also more complex and can (at present) only be used for fitting \(F(f)\) data. Whenever composition drift data is provided, NLLS must be utilized.
The joint confidence region (JCR) of the reactivity ratios is generated using approximate (linear) and/or exact methods. In most cases, the linear method should be sufficiently accurate. Nonetheless, for these types of fits, the exact method is computationally inexpensive, making it perhaps a preferable choice.
Reference
- Van Herk, A.M. and Dröge, T. (1997), Nonlinear least squares fitting applied to copolymerization modeling. Macromol. Theory Simul., 6: 1263-1276.
- Boggs, Paul T., et al. "Algorithm 676: ODRPACK: software for weighted orthogonal distance regression." ACM Transactions on Mathematical Software (TOMS) 15.4 (1989): 348-364.
PARAMETER | DESCRIPTION |
---|---|
data_Ff
|
F(f) instantaneous composition datasets.
TYPE:
|
data_fx
|
f(x) composition drift datasets.
TYPE:
|
data_Fx
|
F(x) composition drift datasets
TYPE:
|
r_guess
|
Initial guess for the reactivity ratios.
TYPE:
|
method
|
Optimization method.
TYPE:
|
alpha
|
Significance level.
TYPE:
|
plot_data
|
If
TYPE:
|
JCR_linear
|
If
TYPE:
|
JCR_exact
|
If
TYPE:
|
JCR_npoints
|
Number of points where the JCR is evaluated. The computational effort
increases linearly with
TYPE:
|
JCR_rtol
|
Relative tolerance for the determination of the JCR. The default value (1e-2) should be adequate in most cases, as it implies a 1% accuracy in the JCR coordinates.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
CopoFitResult
|
Dataclass with all fit results. |
See also
confidence_ellipse
: linear method used to calculate the joint confidence region.confidence_region
: exact method used to calculate the joint confidence region.fit_Finemann_Ross
: alternative method.
Source code in src/polykin/copolymerization/fitting.py
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 |
|