flux
Flux information.
            FluxPoint
    
            ClosedFluxSurface
    Closed poloidal magnetic flux surface.
Source code in tokamak_neutron_source/flux.py
                
            center_of_mass
  
      cached
      property
  
    Centre of mass of the ClosedFluxSurface.
Returns:
| Name | Type | Description | 
|---|---|---|
| com | tuple[float, float] | ClosedFluxSurface center of mass | 
            area
  
      cached
      property
  
    Enclosed area of the ClosedFluxSurface.
Returns:
| Name | Type | Description | 
|---|---|---|
| area | float | ClosedFluxSurface enclosed poloidal area | 
            volume
  
      cached
      property
  
    Volume of the ClosedFluxSurface.
Returns:
| Name | Type | Description | 
|---|---|---|
| volume | float | ClosedFluxSurface enclosed volume. | 
            FluxRing
    
              Bases: tokamak_neutron_source.flux.ClosedFluxSurface
Flux ring.
Source code in tokamak_neutron_source/flux.py
                
            area
  
      property
  
    Enclosed area of the FluxRing.
Returns:
| Name | Type | Description | 
|---|---|---|
| area | FluxRing enclosed poloidal area | 
            center_of_mass
  
      property
  
    Centre of mass of the FluxRing.
Returns:
| Name | Type | Description | 
|---|---|---|
| com | FluxRing center of mass | 
            volume
  
      property
  
    Volume of the FluxRing.
Returns:
| Name | Type | Description | 
|---|---|---|
| volume | FluxRing enclosed volume. | 
            LCFSInformation
    Last closed flux surface parameterisation information.
Source code in tokamak_neutron_source/flux.py
                
            squareness = 0.0
  
      class-attribute
  
    Convert a string or number to a floating point number, if possible.
            FluxSurfaceParameterisation
    
              Bases: abc.ABC
Abstract base class for flux surface parameterisation models.
Source code in tokamak_neutron_source/flux.py
                
            flux_surface(psi_norm, n_points=100)
    Return a ClosedFluxSurface for given psi_norm.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| psi_norm | float | Iterable | Normalised flux | required | 
| n_points | int | Number of points per flux surface | 100 | 
Returns:
| Name | Type | Description | 
|---|---|---|
| flux_surface | ClosedFluxSurface | list[ClosedFluxSurface] | The flux surface at a given psi_norm | 
Source code in tokamak_neutron_source/flux.py
              
            FausserFluxSurface
    
              Bases: tokamak_neutron_source.flux.FluxSurfaceParameterisation
Fausser et al. flux surface parameterisation.
Source code in tokamak_neutron_source/flux.py
                
            SauterFluxSurface
    
              Bases: tokamak_neutron_source.flux.FluxSurfaceParameterisation
Sauter et al. flux surface parameterisation.
Source code in tokamak_neutron_source/flux.py
                
            FluxConvention
    
              Bases: enum.Enum
Flux normalisation convention.
Source code in tokamak_neutron_source/flux.py
                
              
            LINEAR = <FluxConvention.LINEAR: 1>
  
      class-attribute
  
    Flux normalisation convention.
            SQRT = <FluxConvention.SQRT: 2>
  
      class-attribute
  
    Flux normalisation convention.
            FluxInterpolator
    
              Bases: abc.ABC
Abstract base class for FluxInterpolators.
Source code in tokamak_neutron_source/flux.py
                | 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 |  | 
            psi_norm(x, z)
    Get the normalised flux at a given point.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| x | float | Radial coordinate | required | 
| z | float | Vertical coordinate | required | 
Returns:
| Name | Type | Description | 
|---|---|---|
| psi_norm | float | Normalised flux at the point | 
Source code in tokamak_neutron_source/flux.py
              
            get_flux_surface(psi_norm, n_points=None)
    Get a flux surface at a given normalised flux.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| psi_norm | float | Normalised flux | required | 
Returns:
| Name | Type | Description | 
|---|---|---|
| flux_surface | ClosedFluxSurface | Flux surface at the normalised flux | 
Source code in tokamak_neutron_source/flux.py
              
            plot_normalised_flux(ax, levels=None)
    Plot the normalised flux.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| ax | Axes | matplotlib Axes object to use | required | 
| levels | ndarray | None | Normalised psi contour levels to plot | None | 
Returns:
| Name | Type | Description | 
|---|---|---|
| ax | Axes | updated matplotlib Axes | 
Source code in tokamak_neutron_source/flux.py
              
            EQDSKFluxInterpolator
    
              Bases: tokamak_neutron_source.flux.FluxInterpolator
EQDSK FluxInterpolator.
Source code in tokamak_neutron_source/flux.py
                | 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 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 |  | 
            psi_norm(x, z)
    Get the normalised flux at a given point.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| x | float | Radial coordinate | required | 
| z | float | Vertical coordinate | required | 
Returns:
| Name | Type | Description | 
|---|---|---|
| psi_norm | float | Normalised flux at the point | 
Source code in tokamak_neutron_source/flux.py
              
            get_flux_surface(psi_norm, n_points=None)
    Get a flux surface at a given normalised flux.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| psi_norm | float | Normalised flux | required | 
Returns:
| Name | Type | Description | 
|---|---|---|
| flux_surface | ClosedFluxSurface | Flux surface at the normalised flux | 
Source code in tokamak_neutron_source/flux.py
              
            plot_normalised_flux(ax, levels=None)
    Plot the normalised flux.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| ax | Axes | matplotlib Axes object to use | required | 
| levels | ndarray[tuple[Any, ...], dtype[~_ScalarT]] | None | Normalised psi contour levels to plot | None | 
Returns:
| Name | Type | Description | 
|---|---|---|
| ax | Axes | updated matplotlib Axes | 
Source code in tokamak_neutron_source/flux.py
              
            ParameterisationInterpolator
    
              Bases: tokamak_neutron_source.flux.FluxInterpolator
FluxInterpolator from a flux surface parameterisation.
Source code in tokamak_neutron_source/flux.py
                | 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 |  | 
            psi_norm(x, z)
    Get the normalised flux at a given point.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| x | float | Radial coordinate | required | 
| z | float | Vertical coordinate | required | 
Returns:
| Name | Type | Description | 
|---|---|---|
| psi_norm | float | Normalised flux at the point | 
Source code in tokamak_neutron_source/flux.py
              
            get_flux_surface(psi_norm, n_points=None)
    Get a flux surface at a given normalised flux.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| psi_norm | float | Normalised flux | required | 
Returns:
| Name | Type | Description | 
|---|---|---|
| flux_surface | ClosedFluxSurface | Flux surface at the normalised flux | 
Source code in tokamak_neutron_source/flux.py
              
            FluxMap
    Magneto-hydrodynamic equilibrium poloidal magnetic flux map.
Source code in tokamak_neutron_source/flux.py
                | 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 |  | 
            from_eqdsk(file_name, flux_convention=<FluxConvention.LINEAR: 1>)
  
      classmethod
  
    Initialise a FluxMap from an EQDSK.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| file_name | str | EQDSKInterface | EQDSK file name (or the EQDSKInterface) | required | 
| flux_convention | FluxConvention | Flux normalisation convention | <FluxConvention.LINEAR: 1> | 
Returns:
| Name | Type | Description | 
|---|---|---|
| flux_map | FluxMap from the EQDSK | 
Source code in tokamak_neutron_source/flux.py
              
            from_parameterisation(parameterisation, rho_profile, n_points=100, flux_convention=<FluxConvention.LINEAR: 1>)
  
      classmethod
  
    Initialise a FluxMap from a FluxSurfaceParameterisation.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| parameterisation | FluxSurfaceParameterisation | FluxSurfaceParameteristion to use | required | 
| rho_profile | ndarray | Normalised radius array to use | required | 
| n_points | int | Number of points per flux surface | 100 | 
| flux_convention | FluxConvention | Flux normalisation convention | <FluxConvention.LINEAR: 1> | 
Returns:
| Name | Type | Description | 
|---|---|---|
| flux_map | FluxMap from the parameterisation | 
Source code in tokamak_neutron_source/flux.py
              
            psi_norm(x, z)
    Get the normalised flux at a given point.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| x | float | Radial coordinate | required | 
| z | float | Vertical coordinate | required | 
Returns:
| Name | Type | Description | 
|---|---|---|
| psi_norm | float | Normalised flux at the point | 
Source code in tokamak_neutron_source/flux.py
              
            get_flux_surface(psi_norm, n_points=None)
    Get a flux surface at a given normalised flux.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| psi_norm | float | Normalised flux | required | 
Returns:
| Name | Type | Description | 
|---|---|---|
| flux_surface | ClosedFluxSurface | list[ClosedFluxSurface] | Flux surface at the normalised flux | 
Source code in tokamak_neutron_source/flux.py
              
            volume(psi_norm)
    Get the volume at a given normalised flux.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| psi_norm | float | Normalised flux | required | 
Returns:
| Name | Type | Description | 
|---|---|---|
| volume | float | list[float] | Volume at the normalised flux | 
Source code in tokamak_neutron_source/flux.py
              
            plot(f=None, ax=None, levels=None)
    Plot the FluxMap.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| f | Figure | None | Matplotlib figure | None | 
| ax | Axes | None | Matplotlib axes | None | 
| levels | ndarray[tuple[Any, ...], dtype[~_ScalarT]] | None | Normalised psi contour levels to plot | None | 
Returns:
| Name | Type | Description | 
|---|---|---|
| f | Figure | Matplotlib figure | 
| ax | Axes | Matplotlib axes | 
Source code in tokamak_neutron_source/flux.py
              
            FluxSurfaceError
    
            is_closed(x, z, abs_tol=1e-12)
    
            get_contours(x, z, array, value)
    Get the contours of a value in continuous array.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| x | ndarray[tuple[Any, ...], dtype[float64]] | The x value array | required | 
| z | ndarray[tuple[Any, ...], dtype[float64]] | The z value array | required | 
| array | ndarray[tuple[Any, ...], dtype[float64]] | The value array | required | 
| value | float | The value of the desired contour in the array | required | 
Returns:
| Type | Description | 
|---|---|
| list[ndarray[tuple[Any, ...], dtype[float64]]] | The list of arrays of value contour(s) in the array | 
Source code in tokamak_neutron_source/flux.py
              
            find_flux_surf(x, z, psi_norm, psi_norm_value, o_point)
    Picks a flux surface with a normalised psi norm relative to the separatrix. Uses least squares to retain only the most appropriate flux surface. This is taken to be the surface whose geometric centre is closest to the O-point.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| x | ndarray[tuple[Any, ...], dtype[float64]] | The spatial x coordinates of the grid points [m] | required | 
| z | ndarray[tuple[Any, ...], dtype[float64]] | The spatial z coordinates of the grid points [m] | required | 
| psi_norm | ndarray[tuple[Any, ...], dtype[float64]] | The normalised poloidal magnetic flux map [-] | required | 
| psi_norm_value | float | The normalised psi value of the desired flux surface [-] | required | 
| o_point | FluxPoint | O-points to use to calculate psinorm | required | 
Returns:
| Type | Description | 
|---|---|
| ndarray[tuple[Any, ...], dtype[float64]] | The flux surface coordinate array | 
Raises:
| Type | Description | 
|---|---|
| FluxSurfaceError | No flux surface found at psi_norm | 
Notes
\t:math:{\\Psi}_{N} = {\\psi}_{O}-N({\\psi}_{O}-{\\psi}_{X})
Uses matplotlib hacks to pick contour surfaces on psi(X, Z).
Source code in tokamak_neutron_source/flux.py
              
            interpolate_flux_surface(x, z, n_points)
    Source code in tokamak_neutron_source/flux.py
              
            normalise_psi(psi, axis_psi, boundary_psi, convention=<FluxConvention.LINEAR: 1>)
    Normalise flux for a given convention.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| psi | ndarray | Flux | required | 
| axis_psi | float | Magnetic axis flux | required | 
| boundary_psi | float | LCFS flux | required | 
| convention | FluxConvention | Normalised flux convention | <FluxConvention.LINEAR: 1> | 
Returns:
| Name | Type | Description | 
|---|---|---|
| psi_norm | ndarray | Normalised flux | 
Source code in tokamak_neutron_source/flux.py
              
            get_area_2d(x, y)
    Calculate the area inside a closed polygon with x, y coordinate vectors.
Link Shoelace method <https://en.wikipedia.org/wiki/Shoelace_formula>_
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| x | ndarray | The first set of coordinates [m] | required | 
| y | ndarray | The second set of coordinates [m] | required | 
Returns:
| Type | Description | 
|---|---|
| float | The area of the polygon [m^2] | 
Source code in tokamak_neutron_source/tools.py
              
            get_centroid_2d(x, z)
    Calculate the centroid of a non-self-intersecting 2-D counter-clockwise polygon.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| x | ndarray | x coordinates of the coordinates to calculate on | required | 
| z | ndarray | z coordinates of the coordinates to calculate on | required | 
Returns:
| Type | Description | 
|---|---|
| list[float] | The x, z coordinates of the centroid [m] | 
Source code in tokamak_neutron_source/tools.py
              
            load_eqdsk(file)
    Load an EQDSK file.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| file | str | EQDSKInterface | The path to the EQDSK file. | required | 
Returns:
| Type | Description | 
|---|---|
| EQDSKInterface | The EQDSKInterface object. | 
Notes
Enforces the local convention that psi on axis is higher than psi on the boundary. This way, we do not need to ask the user what COCOS convention they are using.
The actual values of psi are irrelevant here, and may be changed to enforce this convention.