|
244 | 244 | ")" |
245 | 245 | ] |
246 | 246 | }, |
| 247 | + { |
| 248 | + "cell_type": "markdown", |
| 249 | + "metadata": {}, |
| 250 | + "source": [ |
| 251 | + "#### Set active coil voltages\n", |
| 252 | + "\n", |
| 253 | + "In this example, we will evolve a plasma in absence of any control policy or current drive.\n", |
| 254 | + "\n", |
| 255 | + "Just as an example, the following calculates active voltages to be applied to the poloidal field coils (and Solenoid) using $V = RI$, with current values as defined by the initial equilibrium (i.e. we have constant voltages).\n", |
| 256 | + "\n", |
| 257 | + "In most FreeGSNKE use cases, these active voltages will be determined by a control policy." |
| 258 | + ] |
| 259 | + }, |
| 260 | + { |
| 261 | + "cell_type": "code", |
| 262 | + "execution_count": null, |
| 263 | + "metadata": {}, |
| 264 | + "outputs": [], |
| 265 | + "source": [ |
| 266 | + "voltages = (stepping.vessel_currents_vec*stepping.evol_metal_curr.coil_resist)[:stepping.evol_metal_curr.n_active_coils] " |
| 267 | + ] |
| 268 | + }, |
| 269 | + { |
| 270 | + "cell_type": "markdown", |
| 271 | + "metadata": {}, |
| 272 | + "source": [ |
| 273 | + "To start, the solver is prepared by setting the initial conditions." |
| 274 | + ] |
| 275 | + }, |
| 276 | + { |
| 277 | + "cell_type": "code", |
| 278 | + "execution_count": null, |
| 279 | + "metadata": {}, |
| 280 | + "outputs": [], |
| 281 | + "source": [ |
| 282 | + "stepping.initialize_from_ICs(eq, profiles)" |
| 283 | + ] |
| 284 | + }, |
247 | 285 | { |
248 | 286 | "cell_type": "markdown", |
249 | 287 | "metadata": {}, |
|
293 | 331 | "metadata": {}, |
294 | 332 | "outputs": [], |
295 | 333 | "source": [ |
296 | | - "voltages = (stepping.vessel_currents_vec*stepping.evol_metal_curr.R)[:stepping.evol_metal_curr.n_active_coils] " |
| 334 | + "voltages = (stepping.vessel_currents_vec*stepping.evol_metal_curr.coil_resist)[:stepping.evol_metal_curr.n_active_coils] " |
297 | 335 | ] |
298 | 336 | }, |
299 | 337 | { |
|
443 | 481 | }, |
444 | 482 | { |
445 | 483 | "cell_type": "code", |
446 | | - "execution_count": 1, |
447 | | - "metadata": {}, |
448 | | - "outputs": [ |
449 | | - { |
450 | | - "ename": "NameError", |
451 | | - "evalue": "name 'plt' is not defined", |
452 | | - "output_type": "error", |
453 | | - "traceback": [ |
454 | | - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", |
455 | | - "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", |
456 | | - "Cell \u001b[0;32mIn[1], line 2\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;66;03m# Plot evolution of tracked values and compare between linear and non-linear evolution\u001b[39;00m\n\u001b[0;32m----> 2\u001b[0m fig, axs \u001b[38;5;241m=\u001b[39m \u001b[43mplt\u001b[49m\u001b[38;5;241m.\u001b[39msubplots(\u001b[38;5;241m3\u001b[39m, \u001b[38;5;241m3\u001b[39m, figsize\u001b[38;5;241m=\u001b[39m(\u001b[38;5;241m15\u001b[39m, \u001b[38;5;241m10\u001b[39m), dpi\u001b[38;5;241m=\u001b[39m\u001b[38;5;241m80\u001b[39m, constrained_layout\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m)\n\u001b[1;32m 3\u001b[0m axs_flat \u001b[38;5;241m=\u001b[39m axs\u001b[38;5;241m.\u001b[39mflat\n\u001b[1;32m 5\u001b[0m axs_flat[\u001b[38;5;241m0\u001b[39m]\u001b[38;5;241m.\u001b[39mplot(history_times, history_o_points[:, \u001b[38;5;241m0\u001b[39m],\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mk+\u001b[39m\u001b[38;5;124m'\u001b[39m, label\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mlinear\u001b[39m\u001b[38;5;124m'\u001b[39m)\n", |
457 | | - "\u001b[0;31mNameError\u001b[0m: name 'plt' is not defined" |
458 | | - ] |
459 | | - } |
460 | | - ], |
| 484 | + "execution_count": null, |
| 485 | + "metadata": {}, |
| 486 | + "outputs": [], |
461 | 487 | "source": [ |
462 | 488 | "# Plot evolution of tracked values and compare between linear and non-linear evolution\n", |
463 | 489 | "fig, axs = plt.subplots(3, 3, figsize=(15, 10), dpi=80, constrained_layout=True)\n", |
|
553 | 579 | "source": [ |
554 | 580 | "## Limited plasma example\n", |
555 | 581 | "\n", |
556 | | - "In this example, we examine a limiter configuration plasma and show how to use time-varying plasma profile parameters and plasma resisitivity." |
| 582 | + "In this example, we examine a limiter configuration plasma and show how to use time-varying plasma profile parameters and plasma resisitivity. Note there is also the option to specify time-dependent active coil resistances. For example, if you want to switch a coil \"off\" during a simulation you can set its resistance to an arbitrarily high number. See the optional parameter `custom_active_coil_resistances`. " |
557 | 583 | ] |
558 | 584 | }, |
559 | 585 | { |
|
648 | 674 | "outputs": [], |
649 | 675 | "source": [ |
650 | 676 | "# determine the (constant) active voltages to be applied at each time step\n", |
651 | | - "voltages = (stepping.vessel_currents_vec*stepping.evol_metal_curr.R)[:stepping.evol_metal_curr.n_active_coils] " |
| 677 | + "voltages = (stepping.vessel_currents_vec*stepping.evol_metal_curr.coil_resist)[:stepping.evol_metal_curr.n_active_coils] " |
652 | 678 | ] |
653 | 679 | }, |
654 | 680 | { |
|
782 | 808 | "metadata": {}, |
783 | 809 | "outputs": [], |
784 | 810 | "source": [ |
| 811 | + "# recalculate the active voltages using the new currents\n", |
| 812 | + "U_active = (stepping.vessel_currents_vec*stepping.evol_metal_curr.coil_resist)[:stepping.evol_metal_curr.n_active_coils] \n", |
| 813 | + "\n", |
| 814 | + "# number of time steps to simulate\n", |
| 815 | + "max_count = 50\n", |
| 816 | + "\n", |
| 817 | + "# reset the solver object by resetting the initial conditions\n", |
| 818 | + "stepping.initialize_from_ICs(eq, profiles)\n", |
| 819 | + "\n", |
785 | 820 | "# initialising some variables for iteration and logging\n", |
786 | 821 | "counter = 0\n", |
787 | 822 | "t = 0\n", |
|
0 commit comments