WorkshopPotentialEAM.ipynb 88.7 KB
 Niklas Leimeroth committed Mar 01, 2021 1 2 { "cells": [  Niklas Leimeroth committed Mar 08, 2021 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26  { "cell_type": "markdown", "id": "ranking-inside", "metadata": {}, "source": [ "# Fitting an EAM potential\n", "EAM potentials are pair functionals. \n", "In a generalised form they are equal to Finnis-Sinclair, effective medium theory or glue potentials. Their total energy can be written as\n", "\n", "$E = \\sum_{ij}V(r_{ij}) + \\sum_i F(\\rho_i)$\n", "\n", "with\n", "\n", "$\\rho_i = \\sum_j \\rho(r_{ij})$\n", "\n", "The original functions for V, $\\rho$ and F were derived from different theories, but they can be chosen freely.\n", "\n", "Fitting is done using atomicrex https://atomicrex.org. In the fit process an objective or cost function is minimized. The objective function is defined as\n", "\n", "$\\chi^2 = \\sum_i w_i r_i$\n", "\n", "where $w_i$ is a weight and $r_i$ is a residual that describes the difference to target values. This residual can be defined in different ways, so it is not possible to simply compare the residual for different fitting processes or codes. A more in depth explanation and some examples can be found on https://atomicrex.org/overview.html#objective-function." ] },  Niklas Leimeroth committed Mar 01, 2021 27 28 29  { "cell_type": "code", "execution_count": 1,  Niklas Leimeroth committed Mar 08, 2021 30  "id": "honey-element",  Niklas Leimeroth committed Mar 01, 2021 31 32 33 34 35  "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "import numpy as np\n",  Niklas Leimeroth committed Mar 08, 2021 36  "import matplotlib.pyplot as plt\n",  Niklas Leimeroth committed Mar 01, 2021 37  "\n",  Jan Janssen committed Mar 06, 2021 38  "from pyiron import Project, ase_to_pyiron"  Niklas Leimeroth committed Mar 01, 2021 39 40  ] },  Niklas Leimeroth committed Mar 08, 2021 41 42 43 44 45 46 47 48  { "cell_type": "markdown", "id": "governing-madagascar", "metadata": {}, "source": [ "### Import the training data" ] },  Niklas Leimeroth committed Mar 01, 2021 49 50 51  { "cell_type": "code", "execution_count": 2,  Niklas Leimeroth committed Mar 08, 2021 52  "id": "constant-respect",  Niklas Leimeroth committed Mar 01, 2021 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95  "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " \n", " \n",  Niklas Leimeroth committed Mar 08, 2021 96  " \n",  Niklas Leimeroth committed Mar 01, 2021 97 98 99 100 101  " \n", " \n", " \n", " \n", " \n",  Niklas Leimeroth committed Mar 08, 2021 102  " \n",  Niklas Leimeroth committed Mar 01, 2021 103 104 105 106  " \n", " \n", " \n", " \n",  Niklas Leimeroth committed Mar 08, 2021 107  " \n",  Niklas Leimeroth committed Mar 01, 2021 108 109 110 111 112 113  " \n", " \n", " \n", " \n", " \n", " \n",  Niklas Leimeroth committed Mar 08, 2021 114  " \n",  Niklas Leimeroth committed Mar 01, 2021 115 116 117 118 119  " \n", " \n", " \n", " \n", " \n",  Niklas Leimeroth committed Mar 08, 2021 120  " \n",  Niklas Leimeroth committed Mar 01, 2021 121 122 123 124  " \n", " \n", " \n", " \n",  Niklas Leimeroth committed Mar 08, 2021 125  " \n",  Niklas Leimeroth committed Mar 01, 2021 126 127 128 129 130 131  " \n", " \n", " \n", " \n", " \n", " \n",  Niklas Leimeroth committed Mar 08, 2021 132  " \n",  Niklas Leimeroth committed Mar 01, 2021 133 134 135 136 137  " \n", " \n", " \n", " \n", " \n",  Niklas Leimeroth committed Mar 08, 2021 138  " \n",  Niklas Leimeroth committed Mar 01, 2021 139 140 141 142  " \n", " \n", " \n", " \n",  Niklas Leimeroth committed Mar 08, 2021 143  " \n",  Niklas Leimeroth committed Mar 01, 2021 144 145 146 147 148 149 150 151 152 153  " \n", " \n", " \n", " \n", " \n", "\n", "" ], "text/plain": [ " id status chemicalformula job \\\n",  Niklas Leimeroth committed Mar 08, 2021 154 155 156  "0 759 finished None df1_A1_A2_A3_EV_elast_phon \n", "1 760 finished None df3_10k \n", "2 761 finished None df2_1k \n",  Niklas Leimeroth committed Mar 01, 2021 157 158 159 160 161 162  "\n", " subjob projectpath \\\n", "0 /df1_A1_A2_A3_EV_elast_phon /home/niklas/pyiron/projects/ \n", "1 /df3_10k /home/niklas/pyiron/projects/ \n", "2 /df2_1k /home/niklas/pyiron/projects/ \n", "\n",  Niklas Leimeroth committed Mar 08, 2021 163 164 165 166 167 168 169 170 171  " project \\\n", "0 pyiron_potentialfit/datasets/imported_datasets/Cu_database/ \n", "1 pyiron_potentialfit/datasets/imported_datasets/Cu_database/ \n", "2 pyiron_potentialfit/datasets/imported_datasets/Cu_database/ \n", "\n", " timestart timestop totalcputime computer \\\n", "0 2021-02-08 10:33:52.341472 None None zora@cmti001#1 \n", "1 2021-02-08 10:33:53.993230 None None zora@cmti001#1 \n", "2 2021-02-08 10:33:54.435308 None None zora@cmti001#1 \n",  Niklas Leimeroth committed Mar 01, 2021 172  "\n",  Niklas Leimeroth committed Mar 08, 2021 173 174 175 176  " hamilton hamversion parentid masterid \n", "0 TrainingContainer 0.4 None None \n", "1 TrainingContainer 0.4 None None \n", "2 TrainingContainer 0.4 None None "  Niklas Leimeroth committed Mar 01, 2021 177 178 179 180 181 182 183 184  ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [  Niklas Leimeroth committed Mar 08, 2021 185  "data_pr = Project(\"../../datasets/imported_datasets/\")\n",  Niklas Leimeroth committed Mar 01, 2021 186  "if len(data_pr.job_table()) == 0:\n",  Niklas Leimeroth committed Mar 08, 2021 187  " data_pr.unpack(\"../../datasets/Cu_training_archive\")\n",  Niklas Leimeroth committed Mar 01, 2021 188 189 190 191 192 193  "data_pr.job_table()" ] }, { "cell_type": "code", "execution_count": 3,  Niklas Leimeroth committed Mar 08, 2021 194  "id": "dirty-measurement",  Niklas Leimeroth committed Mar 01, 2021 195 196 197 198 199 200 201 202 203 204  "metadata": {}, "outputs": [], "source": [ "data_job = data_pr.load(\"df1_A1_A2_A3_EV_elast_phon\")\n", "df = data_job.to_pandas()" ] }, { "cell_type": "code", "execution_count": 4,  Niklas Leimeroth committed Mar 08, 2021 205  "id": "referenced-julian",  Niklas Leimeroth committed Mar 01, 2021 206 207 208 209 210 211 212 213 214 215 216  "metadata": {}, "outputs": [ { "name": "stdin", "output_type": "stream", "text": [ "Are you sure you want to delete all jobs from 'WorkshopPotential'? y/(n) y\n" ] } ], "source": [  Niklas Leimeroth committed Mar 08, 2021 217 218 219 220 221 222 223 224 225 226  "pr = Project(\"WorkshopPotential\")\n", "pr.remove_jobs()" ] }, { "cell_type": "markdown", "id": "voluntary-limit", "metadata": {}, "source": [ "### Create an atomicrex job"  Niklas Leimeroth committed Mar 01, 2021 227 228 229 230 231  ] }, { "cell_type": "code", "execution_count": 5,  Niklas Leimeroth committed Mar 08, 2021 232  "id": "entertaining-jacksonville",  Niklas Leimeroth committed Mar 01, 2021 233 234 235  "metadata": {}, "outputs": [], "source": [  Jan Janssen committed Mar 06, 2021 236  "job = pr.create_job(pr.job_type.Atomicrex, \"PotentialDF1\")"  Niklas Leimeroth committed Mar 01, 2021 237 238 239 240  ] }, { "cell_type": "markdown",  Niklas Leimeroth committed Mar 08, 2021 241  "id": "raising-clear",  Niklas Leimeroth committed Mar 01, 2021 242 243 244 245 246 247 248 249 250  "metadata": {}, "source": [ "### Add the structures that should be fitted.\n", "It is possible to assign different weights to certain structures or properties, depending on what should be investigated using the potential. Here every structure has the same weight, but the force vector with N*3 values is normalized to have the same total weight as the single value energy. Therefore it is divided by the number of atoms. " ] }, { "cell_type": "code", "execution_count": 6,  Niklas Leimeroth committed Mar 08, 2021 251  "id": "located-individual",  Niklas Leimeroth committed Mar 01, 2021 252 253 254 255 256 257 258 259 260 261 262 263  "metadata": {}, "outputs": [], "source": [ "for id, row in df.iterrows():\n", " struct = ase_to_pyiron(row.atoms)\n", " s = job.structures.add_structure(struct, f\"id{id}\", relative_weight=1)\n", " s.fit_properties.add_FitProperty(\"atomic-energy\", target_value=row.energy/row.number_of_atoms, relative_weight=1)\n", " s.fit_properties.add_FitProperty(\"atomic-forces\", target_value=row.forces, relative_weight=1/row.number_of_atoms)" ] }, { "cell_type": "markdown",  Niklas Leimeroth committed Mar 08, 2021 264  "id": "angry-leader",  Niklas Leimeroth committed Mar 01, 2021 265 266 267 268 269 270 271 272 273  "metadata": {}, "source": [ "### Define the type of potential and necessary functions.\n", "In this case an eam potential is fitted." ] }, { "cell_type": "code", "execution_count": 7,  Niklas Leimeroth committed Mar 08, 2021 274  "id": "functional-formation",  Niklas Leimeroth committed Mar 01, 2021 275 276 277 278 279 280 281 282  "metadata": {}, "outputs": [], "source": [ "job.potential = job.factories.potentials.eam_potential()" ] }, { "cell_type": "markdown",  Niklas Leimeroth committed Mar 08, 2021 283  "id": "realistic-karaoke",  Niklas Leimeroth committed Mar 01, 2021 284 285 286 287 288  "metadata": {}, "source": [ "It is necessary to define a pair potential, an electronic density function and an embedding function.\n", "For all of those it is possible to choose between different functional forms.\n", "Classic pair potentials are physically motivated and have a very limited number of paramaters that are derived from a experimentally measured quantity.\n",  Niklas Leimeroth committed Mar 08, 2021 289  "Splines or polynomials offer more flexibility, but can lead to unphysical oscillations or overfitting. Compared with the machine learning potentials shown later the number of parameters is very low no matter which functions you choose and the problem is highly non linear.\n",  Niklas Leimeroth committed Mar 01, 2021 290  "\n",  Niklas Leimeroth committed Mar 08, 2021 291  "In this case a generalized morse function is used for the pair interaction. It has the form\n",  Niklas Leimeroth committed Mar 01, 2021 292  "\n",  Niklas Leimeroth committed Mar 08, 2021 293 294 295 296 297 298  "$(\\frac{D_0}{S-1}exp(-\\beta \\sqrt{2S}(r-r_0))-\\frac{D_0S}{S-1}exp(-\\beta\\sqrt{2/S}(r-r_0)))+\\delta$\n", "\n", "The parameters in the morse potential can be derived from phyiscal quantities, but in this case they are just educated guesses. For example $r_0$ is the equilibrium distance of a dimer. The nearest neighbor distance in fcc Cu is about 2.5 $\\mathring A$ so it is taken as initial value.\n", "In the case of analytic functions the initial parameter choices should not matter too much, since the functional form is constrained.\n", "\n", "The electronic density and embedding function will be splines. Depending on the properties that are calculated other functional forms could give better results. The inital parameters require more testing and hand tuning than the parameters of analytic functions."  Niklas Leimeroth committed Mar 01, 2021 299 300 301 302 303  ] }, { "cell_type": "code", "execution_count": 8,  Niklas Leimeroth committed Mar 08, 2021 304  "id": "interpreted-orange",  Niklas Leimeroth committed Mar 01, 2021 305 306 307  "metadata": {}, "outputs": [], "source": [  Niklas Leimeroth committed Mar 08, 2021 308  "V = job.factories.functions.morse_B(identifier=\"V_CuCu\", D0=0.35, r0=2.5, beta=2, S=2, delta=0)"  Niklas Leimeroth committed Mar 01, 2021 309 310 311 312 313  ] }, { "cell_type": "code", "execution_count": 9,  Niklas Leimeroth committed Mar 08, 2021 314  "id": "mathematical-gasoline",  Niklas Leimeroth committed Mar 01, 2021 315 316 317 318  "metadata": {}, "outputs": [], "source": [ "V.parameters.D0.min_val = 0\n",  Niklas Leimeroth committed Mar 08, 2021 319 320 321 322 323  "V.parameters.D0.max_val = 2\n", "V.parameters.r0.min_val = 1.5\n", "V.parameters.r0.max_val = 3.0\n", "V.parameters.S.min_val = 1.1\n", "V.parameters.S.max_val = 10.0\n",  Niklas Leimeroth committed Mar 01, 2021 324 325 326 327 328 329 330 331  "V.parameters.delta.min_val = -1\n", "V.parameters.delta.max_val = 1\n", "V.parameters.beta.min_val = 0.1\n", "V.parameters.beta.max_val = 10" ] }, { "cell_type": "markdown",  Niklas Leimeroth committed Mar 08, 2021 332  "id": "written-commission",  Niklas Leimeroth committed Mar 01, 2021 333 334 335 336 337 338 339 340  "metadata": {}, "source": [ "Additionally a screening function needs to be defined for the morse potential" ] }, { "cell_type": "code", "execution_count": 10,  Niklas Leimeroth committed Mar 08, 2021 341  "id": "discrete-terminology",  Niklas Leimeroth committed Mar 01, 2021 342 343 344 345 346 347 348 349  "metadata": {}, "outputs": [], "source": [ "V.screening = job.factories.functions.exp_A_screening(identifier=\"V_cutoff\", cutoff=7)" ] }, { "cell_type": "markdown",  Niklas Leimeroth committed Mar 08, 2021 350  "id": "wireless-parts",  Niklas Leimeroth committed Mar 01, 2021 351 352  "metadata": {}, "source": [  Niklas Leimeroth committed Mar 08, 2021 353  "The electron density is chosen to be a spline function. The cutoff has to be defined. Derivatives left and right are optional, they default to 0. For the right cutoff this is fine, since the forces should smoothly go to 0. For the left this is not necessarily the best choice, since the function value should increase at very close distances. Very large absolute values will lead to osciallations and should be avoided."  Niklas Leimeroth committed Mar 01, 2021 354 355 356 357 358  ] }, { "cell_type": "code", "execution_count": 11,  Niklas Leimeroth committed Mar 08, 2021 359  "id": "authentic-expression",  Niklas Leimeroth committed Mar 01, 2021 360 361 362 363 364 365 366 367  "metadata": {}, "outputs": [], "source": [ "rho = job.factories.functions.spline(identifier=\"rho_CuCu\", cutoff=7, derivative_left=-1)" ] }, { "cell_type": "markdown",  Niklas Leimeroth committed Mar 08, 2021 368  "id": "bored-afternoon",  Niklas Leimeroth committed Mar 01, 2021 369 370 371 372 373 374 375 376 377  "metadata": {}, "source": [ "For a spline function it is necessary to define node points. They can be equally spaced or sampled with higher density around turning points, f.e. the first neighbor distance.\n", "Too few nodepoints mean low flexibilty, too many lead to overfitting. This requires some testing to find an optimal choice." ] }, { "cell_type": "code", "execution_count": 12,  Niklas Leimeroth committed Mar 08, 2021 378  "id": "hidden-wildlife",  Niklas Leimeroth committed Mar 01, 2021 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398  "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([0.5 , 1.58, 2.67, 3.75, 4.83, 5.92, 7. ])" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "rho_nodes = np.linspace(0.5, 7.0, 7).round(2)\n", "rho_nodes" ] }, { "cell_type": "markdown",  Niklas Leimeroth committed Mar 08, 2021 399  "id": "binary-devil",  Niklas Leimeroth committed Mar 01, 2021 400 401 402 403 404 405 406 407  "metadata": {}, "source": [ "The nodes need initial values. The electron density should be proportional to $e^{-r}$, so this function is chosen to calculate them." ] }, { "cell_type": "code", "execution_count": 13,  Niklas Leimeroth committed Mar 08, 2021 408  "id": "comparative-brush",  Niklas Leimeroth committed Mar 01, 2021 409 410 411 412 413 414 415 416 417  "metadata": {}, "outputs": [], "source": [ "decaying_exp = lambda r: np.exp(-r)\n", "rho_initial = decaying_exp(rho_nodes)" ] }, { "cell_type": "markdown",  Niklas Leimeroth committed Mar 08, 2021 418  "id": "gentle-infrastructure",  Niklas Leimeroth committed Mar 01, 2021 419 420 421 422 423 424 425 426 427 428  "metadata": {}, "source": [ "Additionally it is a good idea to define limits for the node points. This is optional for local minimizers, but the fit can quickly run away without limits. Global optimizers typically require them to constrain the sampled space.\n", "\n", "A density can't be negative so the lower limit is set to 0. The upper limit is chosen to be 3 times the initial values. These choices aswell as the choice for $e^{-r}$ as initial values are somewhat arbitrary, but don't matter much. The electron density from single atoms does not directly influence the calculated energies and forces, instead the summed up density at some place is used in the embedding function, so the final numerical values are an interplay between electron density and embedding function. Since the latter will also be a spline function it can only be defined for a certain range of rho values as node points. Therefore it is better to limit the range of electron density values and define larger limits for the embedding function instead. " ] }, { "cell_type": "code", "execution_count": 14,  Niklas Leimeroth committed Mar 08, 2021 429  "id": "funny-trinidad",  Niklas Leimeroth committed Mar 01, 2021 430 431 432 433 434 435 436 437 438 439  "metadata": {}, "outputs": [], "source": [ "rho_mins = np.zeros((len(rho_nodes)))\n", "rho_maxs = 3*rho_initial.round(6)\n", "rho.parameters.create_from_arrays(rho_nodes, rho_initial, min_vals=rho_mins, max_vals=rho_maxs)" ] }, { "cell_type": "raw",  Niklas Leimeroth committed Mar 08, 2021 440  "id": "promising-draft",  Niklas Leimeroth committed Mar 01, 2021 441 442 443 444 445 446 447 448  "metadata": {}, "source": [ "Finally the last node point at the cutoff range is set to 0 and fitting is disabled to prevent a discontinuous change of energy at the cutoff." ] }, { "cell_type": "code", "execution_count": 15,  Niklas Leimeroth committed Mar 08, 2021 449  "id": "mexican-absence",  Niklas Leimeroth committed Mar 01, 2021 450 451 452 453 454 455 456 457 458  "metadata": {}, "outputs": [], "source": [ "rho.parameters[\"node_7.0\"].start_val = 0\n", "rho.parameters[\"node_7.0\"].enabled = False" ] }, { "cell_type": "markdown",  Niklas Leimeroth committed Mar 08, 2021 459  "id": "standard-relative",  Niklas Leimeroth committed Mar 01, 2021 460 461 462 463 464 465 466 467 468 469 470  "metadata": {}, "source": [ "$-\\sqrt(\\rho)$ can be used as initial guess for the embedding energy, which is taken from second moment approximation tight binding. \n", "The node points have to be chosen in a range compatible to the electron density. This can be estimated by calculating it for a densely packed structure.\n", "Alternatively atomicrex writes the maximum electron density of all structures to the output. This can be used as a hint for the node points for consequent fits.\n", "Everything else is similar to the electron density." ] }, { "cell_type": "code", "execution_count": 16,  Niklas Leimeroth committed Mar 08, 2021 471  "id": "large-rating",  Niklas Leimeroth committed Mar 01, 2021 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488  "metadata": {}, "outputs": [], "source": [ "F = job.factories.functions.spline(identifier=\"F_CuCu\", cutoff=5)\n", "F_nodes = np.linspace(0.0, 5.0, 7).round(2) #9 is worse 11 is worse 7 is best\n", "F_init = -np.sqrt(F_nodes)\n", "F_maxs = np.zeros(len(F_nodes))\n", "F_mins = -np.ones(len(F_nodes))*5\n", "F.parameters.create_from_arrays(F_nodes, F_init, F_mins, F_maxs)\n", "F.parameters[\"node_0.0\"].enabled=False\n", "F.parameters[\"node_0.0\"].start_val = 0\n", "F.parameters[\"node_5.0\"].enabled=False\n", "F.parameters[\"node_5.0\"].start_val = 0" ] }, { "cell_type": "markdown",  Niklas Leimeroth committed Mar 08, 2021 489  "id": "several-mercy",  Niklas Leimeroth committed Mar 01, 2021 490 491 492 493 494 495 496 497  "metadata": {}, "source": [ "The functions have to be assigned to the potential" ] }, { "cell_type": "code", "execution_count": 17,  Niklas Leimeroth committed Mar 08, 2021 498  "id": "heavy-acoustic",  Niklas Leimeroth committed Mar 01, 2021 499 500 501 502 503 504 505 506 507 508  "metadata": {}, "outputs": [], "source": [ "job.potential.pair_interactions[V.identifier] = V\n", "job.potential.electron_densities[rho.identifier] = rho\n", "job.potential.embedding_energies[F.identifier] = F" ] }, { "cell_type": "markdown",  Niklas Leimeroth committed Mar 08, 2021 509  "id": "alien-chancellor",  Niklas Leimeroth committed Mar 01, 2021 510 511 512 513 514 515 516 517 518 519  "metadata": {}, "source": [ "### Define fitting procedure\n", "Finally a few parameters need to be set that influence the fitting process.\n", "The minimization can be done with different algorithms. Atomicrex itself implements the BFGS algorithm. Additionally the algorithms from the nlopt library can be used." ] }, { "cell_type": "code", "execution_count": 18,  Niklas Leimeroth committed Mar 08, 2021 520  "id": "enormous-segment",  Niklas Leimeroth committed Mar 01, 2021 521 522 523 524 525 526  "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [  Niklas Leimeroth committed Mar 08, 2021 527  "The job PotentialDF1 was saved and received the ID: 819\n"  Niklas Leimeroth committed Mar 01, 2021 528 529 530 531 532 533  ] }, { "data": { "application/json": { "error": "None",  Niklas Leimeroth committed Mar 08, 2021 534 535  "iterations": "array([ 1, 2, 3, ..., 1998, 1999, 2000], dtype=uint32)", "residual": "array([1.39371e+03, 1.39371e+03, 1.39371e+03, ..., 1.52231e-01,\n 1.52231e-01, 1.52231e-01])"  Niklas Leimeroth committed Mar 01, 2021 536 537  }, "text/plain": [  Niklas Leimeroth committed Mar 08, 2021 538 539  "Output({'error': None, 'residual': array([1.39371e+03, 1.39371e+03, 1.39371e+03, ..., 1.52231e-01,\n", " 1.52231e-01, 1.52231e-01]), 'iterations': array([ 1, 2, 3, ..., 1998, 1999, 2000], dtype=uint32)})"  Niklas Leimeroth committed Mar 01, 2021 540 541 542 543 544 545 546 547 548 549  ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "## Define the atom types of the potential\n", "job.input.atom_types.Cu = None\n",  Niklas Leimeroth committed Mar 08, 2021 550 551  "## Limited number of steps for the workshop\n", "job.input.fit_algorithm = job.factories.algorithms.ar_lbfgs(max_iter=2000)\n",  Niklas Leimeroth committed Mar 01, 2021 552 553 554 555 556 557  "job.run()\n", "job.output" ] }, { "cell_type": "markdown",  Niklas Leimeroth committed Mar 08, 2021 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600  "id": "vanilla-chocolate", "metadata": {}, "source": [ "Plot the resiudal over steps to see how the calculation converges" ] }, { "cell_type": "code", "execution_count": 19, "id": "aging-backing", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[]" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" }, { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX0AAAD4CAYAAAAAczaOAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAAAWUUlEQVR4nO3dcZBdZ33e8e8jrS2wwWDjtaNIMpI9KiCTEsyOa0pC6TjENiGW2wwZeUjRJJ5RwzgNtM0kVj1T6Ew1Q5omTWhrZwS4iIZgVAJjtQkpHiUpacfGWRsbWxaOZQS2kLAWMwEDRrbkX/+4R9qrvbsr7d7du/a538945577nvfc89PZ9bNn33Pfe1JVSJKGw7KlLkCSNDiGviQNEUNfkoaIoS9JQ8TQl6QhMrLUBZzK+eefX2vXrl3qMiTpReXee+/9dlWNTm1/wYf+2rVrGR8fX+oyJOlFJck3pmt3eEeShoihL0lDxNCXpCFi6EvSEDll6Ce5LcnhJA9Ns+43klSS87vatibZl+SRJFd1tb8pyYPNug8nycL9MyRJp+N0zvQ/Dlw9tTHJGuDtwONdbRuATcClzTa3JFnerL4V2AKsb756XlOStLhOGfpV9UXgO9Os+k/AbwLdH9O5Ebi9qo5U1X5gH3B5kpXAOVV1V3U+1vMTwHX9Fi9Jmpt5jeknuRb4ZlU9MGXV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