Coverage for python/gsfit/database_readers/st40_spider_mdsplus/setup_wall.py: 0%

20 statements  

« prev     ^ index     » next       coverage.py v7.16.2, created at 2026-10-14 15:25 +0000

1import typing 

2from typing import TYPE_CHECKING 

3 

4import numpy as np 

5import numpy.typing as npt 

6from gsfit_rs import Wall 

7from st40_database import GetData 

8 

9if TYPE_CHECKING: 

10 from . import DatabaseReader 

11 

12 

13# Merging-compression tiles. These protrude inside the vacuum vessel contour, so the plasma 

14# can be limited on them. `MCT` is the top tile and `MCB` the bottom, named after the 

15# merging-compression coils they sit in front of 

16MCT_TILES_R = np.array([0.7103]) # [metre] 

17MCT_TILES_Z = np.array([0.3031]) # [metre] 

18MCB_TILES_R = np.array([0.7103]) # [metre] 

19MCB_TILES_Z = np.array([-0.3131]) # [metre] 

20 

21 

22def setup_wall( 

23 self: "DatabaseReader", 

24 pulseNo: int, 

25 settings: dict[str, typing.Any], 

26) -> Wall: 

27 """ 

28 This method initialises the Rust `Wall` class. 

29 

30 :param pulseNo: Pulse number, used to read from the database 

31 :param settings: Dictionary containing the JSON settings read from the `settings` directory 

32 

33 **This method is specific to ST40's SPIDER MDSplus database.** 

34 

35 See `python/gsfit/database_readers/interface.py` for more details on how a new database_reader should be implemented. 

36 """ 

37 

38 # Vacuum vessel contour, which bounds the region the plasma is allowed to occupy 

39 elmag_run_name = settings["GSFIT_code_settings.json"]["database_reader"]["st40_mdsplus"]["workflow"]["elmag"]["run_name"] 

40 elmag = GetData(pulseNo, f"ELMAG#{elmag_run_name}", is_fail_quiet=False) 

41 vacuum_vessel_r = typing.cast(npt.NDArray[np.float64], elmag.get("LIMITER.LIMIT_PTS.R")) 

42 vacuum_vessel_z = typing.cast(npt.NDArray[np.float64], elmag.get("LIMITER.LIMIT_PTS.Z")) 

43 

44 # Initialise the Wall Rust class 

45 wall = Wall() 

46 

47 # `unit(0)` must be the vacuum vessel contour: the solver reads the limiter units by 

48 # position, and uses the first one, and only the first one, as the region the plasma is 

49 # allowed to occupy. Every unit contributes candidate limit points 

50 wall.add_limiter_unit(name="vacuum_vessel", r=vacuum_vessel_r, z=vacuum_vessel_z) 

51 wall.add_limiter_unit(name="mct_tiles", r=MCT_TILES_R, z=MCT_TILES_Z) 

52 wall.add_limiter_unit(name="mcb_tiles", r=MCB_TILES_R, z=MCB_TILES_Z) 

53 

54 return wall