コード例 #1
0
ファイル: TFripple.py プロジェクト: matval91/TFripple
 def read_file(self, field_fname, coils_fname):
     """ 
     coils,f,eqd = read_file()
     """ 
     try:
         self.coils = h5py.File(coils_fname, "r")
     except:
         print('Impossible to read coil geometry')
         self.coils=[]
     self.f=a5.Ascot(field_fname)
     #self.eqd = ReadEQDSK.ReadEQDSK(eqd_fname)
     self.b5 = Ascotpy(field_fname)
     self.b5.init(bfield=self.f.bfield.active.get_qid())
コード例 #2
0
def loads_on_flag(fname, flag):
    """
	Computes the total walloads on a flag on the wall
	"""
    a5 = a5py.Ascot(fname)
    wallLoad = a5wl.wallLoad3DEndstate(a5)
    wall = a5.wall.active.read()
    flags = wall['flag']
    ind = np.where(flags == flag)[0]
    wallLoad_on_flag = wallLoad[ind]
    x1x2x3 = wall['x1x2x3'][ind]
    y1y2y3 = wall['y1y2y3'][ind]
    z1z2z3 = wall['z1z2z3'][ind]
    return wallLoad_on_flag, x1x2x3, y1y2y3, z1z2z3
コード例 #3
0
import sys
sys.path.append('/home/matval/WORK/pythonscripts')
import utils.plot_utils as pu
import a5py.ascot5io.ascot5 as a5
import numpy as np
import matplotlib.pyplot as plt
import TFripple as tfr
import plot_tips as pt

pu.common_style()

dir = '/home/matval/WORK/ASCOT/runs/SA_003/ripple/pnb/TFripple_w_plasma/perp/2D'
dir = '/home/matval/WORK/ASCOT/runs/SA_003/ripple/nnb/2D/'
#dir='/home/vallar/WORK/ASCOT/runs/SA_003/nnb_ripple/runs_2020/TFripple_newascot_20200728/'
a = a5.Ascot(f'{dir}/ascot.h5')

#run=a.run_1623561441
run = a.active
#B field
fname_bfield = '/home/matval/WORK/ASCOT/runs/SA_003/ripple/nnb/ascot_TFfield_scen003.h5'
fname_bfield = f'{dir}/ascot.h5'
#eqd_fname='/home/matval/WORK/JT60SA/JT-60SA_scenario2_highden_eqdsk_chease_cocos02_smoothed.geq'
#rippleobj = tfr.TFripple(fname_bfield, '')
#R,z, ripple = rippleobj.readfield()
#R,z, ripplewell = rippleobj.calculate_ripplewell()
#wall (better use 2D)
wall = a.wall.wall_2D_3087769866
wall = wall.read()
#wall=a.active.wall

#particles
コード例 #4
0
ファイル: plot_ripple.py プロジェクト: matval91/TFripple
Script to plot the ripple map and well
"""

import utils.plot_utils as pu
import a5py.ascot5io.ascot5 as a5
from a5py.ascotpy.ascotpy import Ascotpy
import os
import numpy as np
import matplotlib.pyplot as plt

pu.common_style()
dir = '/home/vallar/'
if os.uname().nodename != 'spcpc182':
    dir = '/home/matval/'
dir += 'WORK/ASCOT/runs/SA_003/ripple'
a = a5.Ascot(f'{dir}/ascot_TFripple.h5')
b5 = Ascotpy(f'{dir}/ascot_TFripple.h5')
b5.init(bfield=a.bfield.active.get_qid())
# preparing Bfield grids
bb = a.bfield.active.read()
bphi = bb['bphi']
_Rmin = np.squeeze(bb['b_rmin'])
_Rmax = np.squeeze(bb['b_rmax'])
_nR = np.squeeze(bb['b_nr'])
R = np.linspace(_Rmin, _Rmax, _nR)
_zmin = np.squeeze(bb['b_zmin'])
_zmax = np.squeeze(bb['b_zmax'])
_nz = np.squeeze(bb['b_nz'])
z = np.linspace(_zmin, _zmax, _nz)
nphi = np.squeeze(bb['b_nphi'])
Rgrid, zgrid, tg = np.meshgrid(R, z, 0, indexing="ij")
コード例 #5
0
import a5py.ascot5io.ascot5 as a5
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.lines import Line2D
from utils.plot_utils import common_style, define_colors
import matplotlib.ticker as ticker

common_style()
colours, colours_old, styles, my_cmap, dpi= define_colors()
f=a5.Ascot('/home/vallar/WORK/ASCOT/runs/SA_003/fullpower/production/ascot_fullpower_2d_and_3d.h5')
# run_0766036146 RIPPLE
# run_2107319306, 2D - ACTIVE
data={
	'2D':
		{'run':f.run_2107319306,
		},
	'3D':
		{'run':f.run_1162028518,
		}
}
print('data dict created!')
E_edges=np.linspace(10e3, 500e3, 100)
xi_edges=np.linspace(-1, 1., 100)

for label in data.keys():
	endstate = data[label]['run'].endstate
	ind_wall = np.where(endstate['endcond']==32)
	data[label]['ind_wall'] = ind_wall

	E = endstate['energy'][ind_wall] # in J
	data[label]['E_end']=E/1.602e-19 # in keV
コード例 #6
0
ファイル: plot_orbit_EPS.py プロジェクト: matval91/TFripple
import a5py.ascot5io.ascot5 as a5
import matplotlib.pyplot as plt
import ascot5.TFripple.calculate_ripplewell as crw
import numpy as np
from matplotlib.lines import Line2D

f=a5.Ascot('ascot.h5')

run = f.run_0660068410 #NNB
#run = f.run_1992895241 #PP
run2d=f.run_0728205131
#crw.plot_ripplewell()
fig=plt.figure(); ax=fig.add_subplot(111); #axb=fig.add_subplot(212)
#fig=plt.figure(); ax2=fig.add_subplot(111)


R2d=run2d.orbit.get('R')
z2d=run2d.orbit.get('z')
pitch2d=run2d.orbit.get('pitch')
vR2d=run2d.orbit.get('VR')
#ind2d=np.where(np.logical_and(np.abs(pitch2d-0)<0.005,np.abs(vR2d)<1e3))
#ind2d=np.where(np.abs(vR2d)<1e3)
ind2d=np.where(np.abs(pitch2d-0)<0.01)
id=run2d.orbit.get('id')
id_u=np.unique(id)
diff=[]
rini=run2d.inistate.get('R')
rini_x=[]
for index,ids in enumerate(id_u):
    _ind = np.where(id[ind2d]==ids)[0]
    diff = np.append(diff,np.max(R2d[ind2d][_ind])-np.min(R2d[ind2d][_ind]))
コード例 #7
0
"""
Script to plot marker borning position and ripple well
"""
import ascot5.TFripple.calculate_ripplewell as crw 
import numpy as np
import matplotlib.pyplot as plt
import a5py.ascot5io.ascot5 as a5                               
from utils.plot_utils import _plot_2d
fname='/home/vallar/WORK/ASCOT/runs/SA_003/pnb_ripple/perp/ascot_highres.h5'

f=a5.Ascot(fname)
i=f.active.inistate.read()
e=f.active.endstate.read()	

crw.plot_ripplewell()
fig=plt.gcf()
ax=plt.gca()

endcond=e['endcond']
ind=np.where(e['endcond']==8)[0] #wall collision endstate
R=i['r'][ind]; z=i['z'][ind]
w=f.active.wall.read()
rw=w['r']; zw=w['z']
_plot_2d(R, z, ax=ax, hist=1, cblabel='N. markers')
#ax.plot(rw,zw,'k', linewidth=3.)
ax.axis('equal'); ax.grid('on')
fig.tight_layout()
plt.show()
コード例 #8
0
import os
import TFripple.plot_wallloads as pwl
import a5py.ascot5io.ascot5 as a5
import unyt

dir = '/home/vallar'
# if os.uname().nodename!='spcpc182':
#     dir='/home/matval/'
dir += '/WORK/ASCOT/SA_003/ripple/pnb/perp'
# dir+='WORK/ASCOT/SA_003/ripple/pnb/perp/runs_072020/'
fn = f'{dir}/ascot_ripple_pnb_ascot53.h5'
h5 = a5.Ascot(fn)

runs_list = [
    'run_0405154143', 'run_1613197317', 'run_0389017329', 'run_1173810661',
    'run_1720414308'
]
power_on_fild = np.zeros(np.shape(runs_list))
pos = np.zeros(np.shape(runs_list))
max_heatload = np.zeros(np.shape(runs_list))
pitch_for_hist = np.linspace(-1, 0, 20) * 0.5
pitch_on_fild = dict()
for irun, run in enumerate(runs_list):
    rr = h5[run]
    label = rr.get_desc()[0:10]
    ww = rr.wall.read()
    flag_in_run = ww['flagIdList'][-1]
    fild_tiles = np.where(ww['flag'] == flag_in_run)[0]
    area_fildtriangles = rr.wall.area()[fild_tiles]
    xx = ww['x1x2x3'][fild_tiles]
    yy = ww['y1y2y3'][fild_tiles]
コード例 #9
0
                                 vR=inistate['vr'][ind_i_coll],
                                 vphi=inistate['vphi'][ind_i_coll],
                                 vz=inistate['vz'][ind_i_coll],
                                 BR=inistate['br'][ind_i_coll],
                                 Bphi=inistate['bphi'][ind_i_coll],
                                 Bz=inistate['bz'][ind_i_coll],
                                 psi=None)
    print('initial mu', mu)
    return ind, mu


# f=a5.Ascot('/home/vallar/WORK/ASCOT/runs/SA_003/nnb_ripple/production/ascot.h5')
# fcoll=f.run_0665096317
# fnocoll=f.run_0375315118

f = a5.Ascot(
    '/home/vallar/WORK/ASCOT/runs/SA_003/pnb_ripple/perp/run_lowres/ascot.h5')
fcoll = f.run_1717140291  #GO
fnocoll = f.run_0232038243  #GO

orb_coll = fcoll.orbit.read()
orb_nocoll = fnocoll.orbit.read()

ind_coll = np.where(fcoll.endstate['endcond'] == 32)[0]
ind_nocoll = np.where(fnocoll.endstate['endcond'] == 32)[0]

f = plt.figure()
ax_coll_rhopitch = f.add_subplot(121)
ax_nocoll_rhopitch = f.add_subplot(122)

f2 = plt.figure()
ax_coll_rz = f2.add_subplot(121)
コード例 #10
0
common_style()

data={	'NNB':{'fname':'/home/vallar/WORK/ASCOT/runs/SA_003/nnb_ripple/production/ascot.h5',
				'lc':'r', 'label':'N-NB'},
		'pp' :{'fname':'/home/vallar/WORK/ASCOT/runs/SA_003/pnb_ripple/perp/ascot_highres.h5',
				'lc':'g', 'label':'P-perp'},
		'pt' :{'fname':'/home/vallar/WORK/ASCOT/runs/SA_003/pnb_ripple/tang/run_highres/ascot_3D.h5',
				'lc':'b', 'label':'P-tang'}}
#				,
#		'3D' :{'fname':'/home/vallar/WORK/ASCOT/runs/SA_003/fullpower/production/ascot_fullpower_2d_and_3d.h5',
#				'lc':'m', 'label':'3D'}
#}

for el in data.keys():
	f=a5.Ascot(data[el]['fname'])
	#e=f.run_2107319306.endstate.read()
	#i=f.run_2107319306.inistate.read()

	e=f.active.endstate.read()
	i=f.active.inistate.read()

	data[el]['f']=f
	data[el]['e']=e
	data[el]['i']=i
	endcond=e['endcond']
	ind=np.where(e['endcond']==8)[0]
	data[el]['ind_wall']= ind #wall collision endstate
	data[el]['rho_ini'] = i['rho'][ind]
	v_ini = np.sqrt(i['vr']**2+i['vz']**2+i['vphi']**2)
	data[el]['pitch_ini'] = i['vpar'][ind]/v_ini[ind]
コード例 #11
0
                                 R=None,
                                 phi=None,
                                 z=None,
                                 vR=inistate['vr'][ind],
                                 vphi=inistate['vphi'][ind],
                                 vz=inistate['vz'][ind],
                                 BR=inistate['br'][ind],
                                 Bphi=inistate['bphi'][ind],
                                 Bz=inistate['bz'][ind],
                                 psi=None)
    print('initial mu', mu)
    return ind, mu


fname = '/home/vallar/WORK/ASCOT/runs/SA_003/nnb_ripple/production/ascot.h5'
file = a5class.Ascot(fname)
#fgo=file.run_1744124558 # collisions
#fgc=file.run_1659479300 # collisions

fgo = file.run_1893662328  # no collisions, correct orbit diagnostics
fgc = file.run_1357839974  # no collisions

#file=a5.Ascot('/home/vallar/WORK/ASCOT/runs/SA_003/pnb_ripple/perp/run_lowres/ascot.h5')
#fcoll=f.run_1717140291 #GO
#fnocoll=f.run_0232038243 #GO
#fcoll=f.run_2054526193 #GC
#fnocoll=f.run_1434905107 #GC
#fcoll=f.run_1699397937 #GC
#fnocoll=file.run_0032578993 #GC

a5 = Ascotpy(fname)
コード例 #12
0
import a5py.ascot5io.ascot5 as a5
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.lines import Line2D
from utils.plot_utils import common_style, define_colors
import matplotlib.ticker as ticker

common_style()
f = a5.Ascot(
    '/home/vallar/WORK/ASCOT/runs/SA_003/nnb_ripple/production/ascot_nnbripple_worbits.h5'
)
fcoll = f.run_0679501124
fnocoll = f.run_1858977510

tcoll = fcoll.endstate['time'] * 1e3
tnocoll = fnocoll.endstate['time'] * 1e3

ind_coll = np.where(fcoll.endstate['endcond'] == 32)[0]
ind_nocoll = np.where(fnocoll.endstate['endcond'] == 32)[0]

bin_list = np.linspace(0, 30, 100)
fig = plt.figure()
ax = fig.add_subplot(111)
ax.hist(tcoll[ind_coll], histtype='step', bins=bin_list, color='k',\
 label='Coll.', lw=2.3)
ax.hist(tnocoll[ind_nocoll], histtype='step', bins=bin_list, color='r',\
 label='No coll.', lw=2.3)
ax.set_xlabel(r't$_{Lost}$ [ms]')
ax.set_ylabel(r'Markers lost')
ax.legend(loc='best')
ax.grid('on')
コード例 #13
0
    print('initial pitch', pitch)
    energy=eval_mrkr.eval_particle('energy', mass=2.*1.66e-27, charge=None,
                  R=None, phi=None, z=None,
                  vR=inistate['vr'][ind], vphi=inistate['vphi'][ind], vz=inistate['vz'][ind],
                  BR=None, Bphi=None, Bz=None, psi=None)
    print('initial E', energy)
    mu=eval_mrkr.eval_particle('mu', mass=2.*1.66e-27, charge=None,
                  R=None, phi=None, z=None,
                  vR=inistate['vr'][ind], vphi=inistate['vphi'][ind], vz=inistate['vz'][ind],
                  BR=inistate['br'][ind], Bphi=inistate['bphi'][ind], Bz=inistate['bz'][ind], psi=None)
    print('initial mu', mu)
    return ind, mu


fname='/home/vallar/WORK/ASCOT/runs/SA_003/nnb_ripple/production/ascot.h5'
file=a5.Ascot(fname)
fcoll=file.run_1659479300
fnocoll=file.run_1357839974

#file=a5.Ascot('/home/vallar/WORK/ASCOT/runs/SA_003/pnb_ripple/perp/run_lowres/ascot.h5')
#fcoll=f.run_1717140291 #GO
#fnocoll=f.run_0232038243 #GO
#fcoll=f.run_2054526193 #GC
#fnocoll=f.run_1434905107 #GC
#fcoll=f.run_1699397937 #GC
#fnocoll=file.run_0032578993 #GC

a5 = Ascotpy(fname); a5.init(bfield=True)
orb_coll=fcoll.orbit.read()
orb_nocoll=fnocoll.orbit.read()
ind_nocoll=np.where(fnocoll.endstate['endcond']==4)[0]