0001 function [equil] = make_equil_TORPEX
0002
0003
0004
0005
0006
0007 clear all
0008 close all
0009 clc
0010
0011 id = 'TORPEX';
0012
0013 B_torpex_data_x = load('Sources/B_V_x.txt','-ascii');
0014 B_torpex_data_y = load('Sources/B_Tbc_y.txt','-ascii');
0015 B_torpex_data_z = load('Sources/B_V_z.txt','-ascii');
0016
0017 ne_torpex_data = load('Sources/ne.txt','-ascii');
0018
0019 if sum(sum(B_torpex_data_x(1:2,:) - B_torpex_data_y(1:2,:)) + sum(B_torpex_data_x(1:2,:) - B_torpex_data_z(1:2,:)) + sum(B_torpex_data_y(1:2,:) - B_torpex_data_z(1:2,:))) ~= 0,
0020 error('ERROR: inconsistent raw TORPEX B data');
0021 end
0022
0023 if sum(sum(B_torpex_data_x(1:2,:) - ne_torpex_data(1:2,:))) ~= 0,
0024 error('ERROR: inconsistent raw TORPEX ne data');
0025 end
0026
0027 Rp = (B_torpex_data_x(1,end) + B_torpex_data_x(1,1))/2;
0028 Zp = (B_torpex_data_x(2,end) + B_torpex_data_x(2,1))/2;
0029
0030 xyx = B_torpex_data_x(1,:) - Rp;
0031 xyy = B_torpex_data_x(2,:) - Zp;
0032
0033 xyBx = B_torpex_data_x(3:end,:);
0034 xyBy = B_torpex_data_z(3:end,:);
0035 xyBz = B_torpex_data_y(3:end,:);
0036
0037 xyne = ne_torpex_data(3:end,:);
0038 xyTe = zeros(size(xyne));
0039
0040 zZi = [1,1,1,2];
0041 zmi = [1,2,3,4];
0042 zfi = [1,0,0];
0043 zeff = 1;
0044
0045 xyzTi = repmat(zeros(size(xyne)),[length(zZi),1]);
0046 xyzni = species_dke_yp(xyne,zeff,zZi,zfi);
0047
0048 equil.id = id;
0049
0050 equil.Rp = Rp;
0051 equil.Zp = Zp;
0052
0053 equil.xyx = xyx;
0054 equil.xyy = xyy;
0055
0056 equil.xyBx = xyBx;
0057 equil.xyBy = xyBy;
0058 equil.xyBz = xyBz;
0059
0060 equil.xyTe = xyTe;
0061 equil.xyne = xyne;
0062
0063 equil.zZi = zZi;
0064 equil.zmi = zmi;
0065 equil.zfi = zfi;
0066
0067 equil.xyzTi = xyzTi;
0068 equil.xyzni = xyzni;
0069
0070
0071
0072 [xyR,xyZ] = meshgrid(xyx + Rp,xyy + Zp);
0073
0074 figure('Name','Radial magnetic field'),graph2D_jd(xyR,xyZ,xyBx.','R[m]','Z[m]','Radial magnetic field Bx [Tesla]',[],[],1);axis('equal'),colorbar;
0075 figure('Name','Vertical magnetic field'),graph2D_jd(xyR,xyZ,xyBy.','R[m]','Z[m]','Vertical magnetic field By [Tesla]',[],[],1);axis('equal'),colorbar;
0076 figure('Name','Toroidal magnetic field'),graph2D_jd(xyR,xyZ,xyBz.','R[m]','Z[m]','Toroidal magnetic field Bz [Tesla]',[],[],1);axis('equal'),colorbar;
0077 figure('Name','Electron density'),graph2D_jd(xyR,xyZ,xyne.','R[m]','Z[m]','Interpolated electron density n_e[m^{-3}]',[],[],1);axis('equal'),colorbar;
0078
0079 filename = ['EQUIL_',equil.id,'.mat'];
0080
0081 eval(['save ',filename,' equil']);
0082
0083 [equil_fit] = fitequil_yp(equil,2,'spline');
0084
0085 [equil_val] = equilval_yp(equil_fit,[-0.015,0.12,0.027;0.18,-0.02,0.0],[0.017,0.19,-0.03;-0.15,0.1,0.03]);
0086
0087