@@ -108,6 +108,8 @@ def __init__(self,OFT_env):
108108 self .coil_sets = {}
109109 ## Virtual coils, if present (currently only `'#VSC'`)
110110 self ._virtual_coils = {'#VSC' : {'id' : - 1 ,'facs' : {}}}
111+ ## Voltage coils dictionary. Currently only used for plotting on python side.
112+ self ._vcoils = {}
111113 ## Coil set names in order of id number
112114 self .coil_set_names = []
113115 ## Distribution coils, only (currently) saved for plotting utility
@@ -182,6 +184,7 @@ def reset(self):
182184 self ._cond_dict = {}
183185 self ._vac_dict = {}
184186 self ._coil_dict = {}
187+ self ._vcoils = {}
185188 self .coil_sets = {}
186189 self ._virtual_coils = {'#VSC' : {'id' : - 1 ,'facs' : {}}}
187190 self ._F0 = 0.0
@@ -644,6 +647,8 @@ def set_vcoils(self,coil_resistivities):
644647 tokamaker_set_vcoil (self ._tMaker_ptr ,res_array ,error_string )
645648 if error_string .value != b'' :
646649 raise Exception (error_string .value )
650+ #Merge dicts and overwrite with new values where necessary. Only used for plotting.
651+ self ._vcoils = self ._vcoils | coil_resistivities
647652
648653 def init_psi (self , r0 = - 1.0 , z0 = 0.0 , a = 0.0 , kappa = 0.0 , delta = 0.0 , curr_source = None ):
649654 r'''! Initialize \f$\psi\f$ using uniform current distributions
@@ -1098,7 +1103,7 @@ def get_jtor_plasma(self):
10981103 tokamaker_get_jtor (self ._tMaker_ptr ,curr ,error_string )
10991104 if error_string .value != b'' :
11001105 raise Exception (error_string .value )
1101- return curr / mu0
1106+ return curr
11021107
11031108 def get_psi (self ,normalized = True ):
11041109 r'''! Get poloidal flux values on node points
@@ -1625,6 +1630,16 @@ def get_conductor_currents(self,psi,cell_centered=False):
16251630 if cell_centered :
16261631 mesh_currents [mask_tmp ] = numpy .sum (curr [self .lc [mask_tmp ,:]],axis = 1 )/ 3.0
16271632 mask = numpy .logical_or (mask ,mask_tmp )
1633+
1634+ # Treat vcoils as conductors when looking at induced currents
1635+ for coil_name , coil_obj in self .coil_sets .items ():
1636+ if coil_name in self ._vcoils .keys ():
1637+ for sub_coil in coil_obj ["sub_coils" ]:
1638+ mask_tmp = self .reg == sub_coil ['reg_id' ]
1639+ if cell_centered :
1640+ mesh_currents [mask_tmp ] = numpy .mean (curr [self .lc [mask_tmp ]],axis = 1 )
1641+ mask = numpy .logical_or (mask ,mask_tmp )
1642+
16281643 if cell_centered :
16291644 return mask , mesh_currents
16301645 else :
@@ -1663,6 +1678,16 @@ def get_conductor_source(self,dpsi_dt):
16631678 if cond_reg .get ('noncontinuous' ,False ):
16641679 mesh_currents [mask_tmp ] -= (mesh_currents [mask_tmp ]* area [mask_tmp ]).sum ()/ area [mask_tmp ].sum ()
16651680 mask = numpy .logical_or (mask ,mask_tmp )
1681+
1682+ # Treat vcoils as conductors when looking at induced currents
1683+ for coil_name , coil_obj in self .coil_sets .items ():
1684+ if coil_name in self ._vcoils .keys ():
1685+ for sub_coil in coil_obj ["sub_coils" ]:
1686+ mask_tmp = self .reg == sub_coil ['reg_id' ]
1687+ field_tmp = - dpsi_dt / self ._vcoils [coil_name ]
1688+ mesh_currents [mask_tmp ] = numpy .mean (field_tmp [self .lc [mask_tmp ]],axis = 1 )
1689+ mask = numpy .logical_or (mask ,mask_tmp )
1690+
16661691 return mask , mesh_currents
16671692
16681693 def plot_eddy (self ,fig ,ax ,psi = None ,dpsi_dt = None ,nlevels = 40 ,colormap = 'jet' ,clabel = r'$J_w$ [$A/m^2$]' ,symmap = False ):
0 commit comments