Ejemplo n.º 1
0
def map_field_lines(x_vec_at_omp, file_path, configuration='diverted'):
    '''
    Function for mapping each field-line to the intersection with the vessel walls

    Input: x_vec_at_omp,  a numpy array with the radial points at the OMP where
                          we want the mapping to start
           file_path,     a string with the path to the FIESTA equilibrium .mat file
           configuration, a string with either 'limited' or 'diverted', where 'diverted'
                          is the defualt configuration

    return: field_line_dict, a python dictionary with the radial position from the OMP in m
                             as the key and the field-line dictionary with the R, phi
                             and Z components along the field line as well as the length, l,
                             from the LCFS to the current point along the field-line
    '''
    field_line = FieldLine(file_path)
    field_line_dict = {}
    for i in x_vec_at_omp:
        field_lines = field_line.follow_field_in_plane(p_0=[i, 0, 0], max_length=10.0)

        func1 = np.array([field_lines["R"], field_lines["Z"]])
        func2 = np.array([field_line.fiesta_equil.r_limiter, field_line.fiesta_equil.z_limiter])

        (i_intersect_func1, _),\
        (r_intersect, z_intersect) = intersection(func1, func2)
        if not np.any(np.isnan(r_intersect)):
            i_int = int(np.floor(i_intersect_func1))
            i_first_intersect = np.argmin(field_lines["l"][i_int])
            i_intersection = i_intersect_func1[i_first_intersect]
            i_intersection = int(np.ceil(i_intersection))
            if configuration == 'limited':
                i_min_intersect = np.argmin(field_lines["R"][i_intersection] - r_intersect)
                i_intersection = np.where(field_lines["R"][:] < r_intersect[i_min_intersect])[0][0]
            elif configuration == 'diverted':
                i_min_intersect = np.argmin(field_lines["Z"][i_intersection] - z_intersect)
                i_intersection = np.where(field_lines["Z"][:] < z_intersect[i_min_intersect])[0][0]
            else:
                raise NotImplementedError("Error: unknown configuration.\
                                          Please use either 'limited' or 'diverted'")

            field_lines["l"] = field_lines["l"][:i_intersection+1]
            field_lines["R"] = field_lines["R"][:i_intersection+1]
            field_lines["Z"] = field_lines["Z"][:i_intersection+1]

            field_lines["Vessel_Intersect"] = (r_intersect[i_min_intersect],
                                               z_intersect[i_min_intersect])

            field_line_dict[i] = field_lines
        else:
            field_lines["Vessel_Intersect"] = (np.nan, np.nan)
            field_line_dict[i] = field_lines

    return field_line_dict
Ejemplo n.º 2
0
from vita.modules.projection.projection2D.field_line.field_line import FieldLine
from vita.modules.equilibrium.fiesta.fiesta_interface import Fiesta
from vita.modules.sol_heat_flux.eich.eich import Eich
from vita.modules.utils.getOption import getOption


if __name__ == '__main__':
    #HESEL_FILE_PATH = '/media/jmbols/Data/jmbols/ST40/Programme 3/Te(i)_grad_scan/ST40.00003.20.h5'
    #HESELDATA = HESELdata(HESEL_FILE_PATH)
    #HESELDATA.evaluate_parallel_heat_fluxes()

    FILEPATH = get_resource("ST40-IVC1", "equilibrium", "eq_006_2T_export")

    FIESTA = Fiesta(FILEPATH)

    FIELD_LINE = FieldLine(FIESTA)
    MID_PLANE_LOC = FIESTA.get_midplane_lcfs()[1]

    #I_AFTER_LCFS = np.linspace(-1, 10, 100)*1e-3
    #I_AFTER_LCFS = np.where(HESELDATA.hesel_params.xaxis >= 0)[0]
    # specify and load heatflux profile
    FOOTPRINT = Eich(0.0025, 0.0005, r0_lfs=MID_PLANE_LOC)  # lambda_q=2.5, S=0.5

    X_OMP = np.linspace(0, 10, 100)*1e-3
    FOOTPRINT.set_coordinates(X_OMP)
    FOOTPRINT.s_disconnected_dn_max = 2.1
    FOOTPRINT.fx_in_out = 5.
    FOOTPRINT.calculate_heat_flux_density("lfs")

    Q_PARALLEL = np.array(FOOTPRINT._q)
    X_AFTER_LCFS = np.array(FOOTPRINT.get_global_coordinates())
Ejemplo n.º 3
0
from vita.modules.projection.projection2D.field_line.map_field_lines import map_field_lines
from vita.modules.utils.getOption import getOption

if __name__ == "__main__":
    #FILEPATH = '/home/jmbols/Postdoc/ST40/Programme 1/Equilibrium/eq001_limited.mat'
    #FILEPATH = '/media/jmbols/Data/jmbols/ST40/Programme 3/Equilibrium/eq_0002.mat'
    FILEPATH = get_resource("ST40-IVC1", "equilibrium", "eq_006_2T_export")
   #HESEL_FILE_PATH = '/media/jmbols/Data/jmbols/ST40/Programme 1/n_inner_bnd_scan/ST40.00001.03.h5'
    #HESEL_FILE_PATH = '/media/jmbols/Data/jmbols/ST40/Programme 3/Te(i)_grad_scan/ST40.00003.20.h5'

    #FILE = h5py.File(HESEL_FILE_PATH, 'r')
    #HESEL_PARAMS = HESELparams(FILE)
    #FILE.close()
    FIESTA = Fiesta(FILEPATH)

    FIELD_LINE = FieldLine(FIESTA)
    MID_PLANE_LOC = FIESTA.get_midplane_lcfs()[1]

    X_AFTER_LCFS = np.linspace(0, 10, 100)*1e-3 + MID_PLANE_LOC

#    I_AFTER_LCFS = np.where(HESEL_PARAMS.xaxis >= 0)[0]
#    X_AFTER_LCFS = HESEL_PARAMS.xaxis[I_AFTER_LCFS] + MID_PLANE_LOC

    FIELD_LINES = map_field_lines(X_AFTER_LCFS, FIESTA)
#    save_as_pickle(FIELD_LINES, 'eq_0002')

    plt.plot(FIELD_LINE.fiesta_equil.r_limiter, FIELD_LINE.fiesta_equil.z_limiter)
    for I in X_AFTER_LCFS:
        plt.plot(FIELD_LINES[I]['R'], FIELD_LINES[I]['Z'])
        plt.plot(FIELD_LINES[I]['Vessel_Intersect'][0], FIELD_LINES[I]['Vessel_Intersect'][1], '*')
            
Ejemplo n.º 4
0
"""
Created on Sun Oct 20 18:28:22 2019

@author: Daniel.Ibanez
"""
import numpy as np
from matplotlib import pyplot as plt

from vita.modules.equilibrium.fiesta import Fiesta
from vita.modules.projection.projection2D.field_line.field_line import FieldLine
from vita.utility import get_resource
from vita.modules.utils.getOption import getOption

R200 = get_resource("ST40-IVC1", "equilibrium", "eq_006_2T_export")
FIESTA = Fiesta(R200)
field_line =  FieldLine(FIESTA)

R = FIESTA.get_midplane_lcfs()[1]
r0 = 0.45
rf = R+0.01
midplane_range = np.linspace(r0,rf,3)
points = []
lengths = []
for r in midplane_range:
    points.append( [r,0,0] )
    lengths.append( 60 - (r-r0)*120 )
print(lengths)
field_line_dict = []
for idx, val in enumerate(points):
    field_line_dict.append(field_line.follow_field_in_plane(val, lengths[idx], break_at_limiter=False) )
f, ax = plt.subplots(1)
Ejemplo n.º 5
0
def project_field_lines(x_axis_omp, surface_coords, fiesta):
    '''
    Function mapping the field-lines from the specified coordinates at the
    OMP to the specified coordinates at a given surface. Currently the surface
    is assumed to be represented by a 1D polynomial function, y = ax + b.

    Parameters
    ----------
    x_axis_omp : n-x-1 np.array
        Numpy array with the radial coordinates we wish to map at the OMP
    fiesta : Fiesta
        A Fiesta object with the 2D equilibrium we wish to map
    divertor_coords : 2-x-2 np.array
        A 2-x-2 numpy array containg the corner points of the divertor in the
        2D projection

    Returns
    -------
    divertor_map : dictionary
        A dictionary containing:
            "R_div" : an n-x-1 array
                with the R-coordinates at the divertor tile
                corresponding to the same psi_n as at the OMP
            "Z_div" : an n-x-1 array
                with the Z-coordinates at the divertor tile
                corresponding to the same psi_n as at the OMP
            "Angles" : an n-x-1 array
                with the angles between the field lines and the divertor tile
                corresponding to the same psi_n as at the OMP
            "Flux_expansion" : an n-x-1 array
                with the flux expasion at the divertor tile
                corresponding to the same psi_n as at the OMP

    '''
    # Interpolate b_pol (to be used when evaluating the flux expansion)
    b_pol = fiesta.b_theta.T
    b_pol_interp = Interpolate2DCubic(fiesta.r_vec, fiesta.z_vec, b_pol)

    field_lines = {}

    if os.path.exists("Random_filename"):
        field_lines = load_pickle("Random_filename")
    else:
        field_line = FieldLine(fiesta)
        for i in x_axis_omp:
            p_0 = [i, 0, 0]
            field_line_dict = field_line.follow_field_in_plane(p_0=p_0,
                                                               max_length=15.0)
            field_lines[i] = field_line_dict

    _v_2 = np.array([
        surface_coords[0, 1] - surface_coords[0, 0],
        surface_coords[1, 1] - surface_coords[1, 0]
    ])

    divertor_map = {}
    for i in field_lines:
        func1 = np.array((field_lines[i]['R'], field_lines[i]['Z']))
        (i_func1, _), (x_at_surface,
                       y_at_surface) = intersection(func1, (surface_coords))
        if np.isnan(x_at_surface):
            break

        _x_component = field_lines[i]['R'][int(i_func1)] - field_lines[i]['R'][
            int(i_func1) + 1]
        _y_component = field_lines[i]['Z'][int(i_func1)] - field_lines[i]['Z'][
            int(i_func1) + 1]
        _v_1 = [_x_component, _y_component]

        temp_dict = {}
        temp_dict["R_pos"] = x_at_surface[0]
        temp_dict["Z_pos"] = y_at_surface[0]
        temp_dict["alpha"] = calculate_angle(_v_1, _v_2)
        temp_dict["f_x"] = _flux_expansion(b_pol_interp, (i, 0),
                                           (x_at_surface[0], y_at_surface[0]))
        divertor_map[i] = temp_dict

    return divertor_map
from vita.modules.projection.projection2D.field_line.field_line import FieldLine
from vita.modules.projection.projection2D.field_line.field_line_projection import project_field_lines
from vita.modules.equilibrium.fiesta.fiesta_interface import Fiesta
from vita.modules.sol_heat_flux.eich.eich import Eich
from cherab.core.math import Interpolate2DCubic
from vita.modules.projection.projection2D.psi_map_projection import map_psi_omp_to_divertor
from vita.modules.projection.projection2D.project_heat_flux import project_heat_flux

if __name__ == "__main__":
    FILEPATH = get_resource("ST40", "equilibrium", "eq002")

    FIESTA = Fiesta(FILEPATH)
    B_POL = np.sqrt(FIESTA.b_r**2 + FIESTA.b_theta**2 + FIESTA.b_z**2).T
    B_POL_INTERP = Interpolate2DCubic(FIESTA.r_vec, FIESTA.z_vec, B_POL)

    FIELD_LINE = FieldLine(FILEPATH)
    MID_PLANE_LOC = FIESTA.get_midplane_lcfs()[1]

    FOOTPRINT = Eich(0.0025, 0.0005,
                     r0_lfs=MID_PLANE_LOC)  # lambda_q=2.5, S=0.5

    X_OMP = np.linspace(0, 10, 100) * 1e-3
    FOOTPRINT.set_coordinates(X_OMP)
    FOOTPRINT.s_disconnected_dn_max = 2.1
    FOOTPRINT.fx_in_out = 5.
    FOOTPRINT.calculate_heat_flux_density("lfs")

    Q_PARALLEL = FOOTPRINT._q
    X_AFTER_LCFS = FOOTPRINT.get_global_coordinates()

    DIVERTOR_COORDS = np.array((np.array([0.375,
Ejemplo n.º 7
0
"""
Created on Sun Oct 20 18:28:22 2019

@author: Daniel.Ibanez
"""
import numpy as np
from matplotlib import pyplot as plt

from vita.modules.equilibrium.fiesta import Fiesta
from vita.modules.projection.projection2D.field_line.field_line import FieldLine
from vita.utility import get_resource
from vita.modules.utils.getOption import getOption

R200 = get_resource("ST40-IVC1", "equilibrium", "eq_006_2T_export")
FIESTA = Fiesta(R200)
field_line = FieldLine(FIESTA)
R = FIESTA.get_midplane_lcfs()[0]
print(R)
r0 = 0.45
rf = R - 0.1
midplane_range = np.linspace(rf, r0, 5)
points = []
lengths = []
for r in midplane_range:
    points.append([r, 0, 0])
    lengths.append(120)
print(lengths)
field_line_dict = []
for idx, val in enumerate(points):
    field_line_dict.append(
        field_line.follow_field_in_plane(val,