Skip to content

Commit

Permalink
Merge pull request #173 from taiga-project/feature-166
Browse files Browse the repository at this point in the history
Feature 166
  • Loading branch information
matyasaradi authored Jan 13, 2024
2 parents 976f374 + 1d24394 commit 4fc9171
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 30 deletions.
19 changes: 10 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ LIBS = -lcurand

VERSION = -D'TAIGA_VERSION="$(shell git branch | grep \* | cut -d ' ' -f2)"' -D'GIT_REV="$(shell git show -s --pretty=format:%h)"'

DEFAULT_FLAGS = $(VERSION) -D'RENATE=0' -D'FASTMODE=0' -fcommon
DEFAULT_FLAGS = $(VERSION) -D'RENATE=0' -D'FASTMODE=0'
RENATE_FLAGS = $(VERSION) -D'RENATE=1' -D'FASTMODE=0'
RENATE_FAST_FLAGS = $(VERSION) -D'RENATE=1' -D'FASTMODE=1'
TEST_FLAGS = $(VERSION) -fcommon

OBJ=build
BIN=bin
Expand All @@ -33,28 +34,28 @@ taiga_renate_fast.exe: src/main.cu | $(BIN)
t: test

test: $(OBJ)/tests.o $(OBJ)/test_bspline.o $(OBJ)/test_solver.o $(OBJ)/test_basic_functions.o $(OBJ)/basic_functions.o | $(BIN)
$(GCC) $(DEFAULT_FLAGS) -Isrc -Itests $^ -lm -o $(BIN)/test.exe
$(GCC) $(TEST_FLAGS) -Isrc -Itests $^ -lm -o $(BIN)/test.exe

$(OBJ)/%.o: tests/%.c $(OBJ)
$(GCC) $(DEFAULT_FLAGS) -w -Isrc -Iinclude -Itests -c $< -lm -o $@
$(GCC) $(TEST_FLAGS) -w -Isrc -Iinclude -Itests -c $< -lm -o $@

$(OBJ)/basic_functions.o: src/utils/basic_functions.c $(OBJ)
$(GCC) $(DEFAULT_FLAGS) -w -Isrc -Iinclude -Itests -I$utils -c $< -o $@
$(GCC) $(TEST_FLAGS) -w -Isrc -Iinclude -Itests -I$utils -c $< -o $@

test_init: tests | $(BIN)
$(NVCC) $(CFLAGS) $(DEFAULT_FLAGS) -o $(BIN)/test_init.exe tests/test_taiga_init.cu
$(NVCC) $(CFLAGS) $(TEST_FLAGS) -o $(BIN)/test_init.exe tests/test_taiga_init.cu

test_framework: tests | $(BIN)
$(GCC) $(DEFAULT_FLAGS) -o $(BIN)/test_framework.exe tests/taiga_test_example.c
$(GCC) $(TEST_FLAGS) -o $(BIN)/test_framework.exe tests/taiga_test_example.c

example_solvers: $(OBJ)/example_solvers.o $(OBJ)/test_solver.o | $(BIN)
$(GCC) $(DEFAULT_FLAGS) $^ -lm -o $(BIN)/example_solvers.exe
$(GCC) $(TEST_FLAGS) $^ -lm -o $(BIN)/example_solvers.exe

$(OBJ)/example_solvers.o: example/solvers/export_solver.c $(OBJ)
$(GCC) $(DEFAULT_FLAGS) -w -Isrc -Iinclude -Itests -c $< -lm -o $@
$(GCC) $(TEST_FLAGS) -w -Isrc -Iinclude -Itests -c $< -lm -o $@

field: tests | $(BIN)
$(NVCC) $(CFLAGS) $(DEFAULT_FLAGS) -o $(BIN)/test_field.exe tests/test_field.cu
$(NVCC) $(CFLAGS) $(TEST_FLAGS) -o $(BIN)/test_field.exe tests/test_field.cu

$(OBJ):
mkdir $@
Expand Down
1 change: 1 addition & 0 deletions include/utils/prop.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ typedef struct BeamProp{

typedef struct ShotProp{
char name[STRING_LENGTH];
char long_name[STRING_LENGTH];
char shotnumber[STRING_LENGTH];
char time[STRING_LENGTH];
char detector_mask[STRING_LENGTH];
Expand Down
6 changes: 5 additions & 1 deletion preproc/renate_od/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@

import manager
from manager import RenateODManager
from beamlet import set_beamlet
from efit import EFITManager
from utils import *
29 changes: 14 additions & 15 deletions preproc/renate_od/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,29 @@
from utils import *


def export_beamlet_profile(export_root=get_home_directory() + '/input/ionProf/',
def export_beamlet_profile(export_root=os.path.join(get_home_directory(), 'input', 'ionProf'),
shot_number='17178', time='1097', species='Li', energy='80'):
z = 0
tor = 0
beamlet_geometry = set_beamlet(z, tor)
r = RenateODManager(beamlet_geometry, shot_number, time, species, energy)
radial_coordinate, relative_attenuation = r.get_attenuation_profile()

export_directory = export_root + '/'+shot_number+'_'+time
export_directory = os.path.join(export_root, shot_number + '_' + time, species, energy)
try:
os.mkdir(export_directory)
os.makedirs(export_directory)
print('Create directory and write data to ' + export_directory)
except FileExistsError:
print('Write data to ' + export_directory)
else:
pass
except OSError as error:
print('Cannot create and write to ' + export_directory)
print('Save RENATE-OD ionisation profile to: ' + export_directory)
radial_coordinate.fillna(0).to_csv(export_directory+'/rad.dat', index=False, header=False)
relative_attenuation.fillna(0).to_csv(export_directory+'/ionyeald.dat', index=False, header=False)
radial_coordinate.fillna(0).to_csv(os.path.join(export_directory, 'rad.dat'), index=False, header=False)
relative_attenuation.fillna(0).to_csv(os.path.join(export_directory, 'ionyeald.dat'), index=False, header=False)
plot_attenuation_profile(shot_number, time, radial_coordinate, relative_attenuation, export_directory)


def get_lcfs_radial_coordinate(shot_number, time, efit_reconstruction_id=1, database_directory='input/cdb', efit_subdir='EFITXX'):
data_directory = get_home_directory() + '/' + database_directory + '/' + str(shot_number)
efit_file = data_directory + '/' + efit_subdir + '/' + 'EFITXX.' + str(efit_reconstruction_id) + '.h5'
data_directory = os.path.join(get_home_directory(), database_directory, str(shot_number))
efit_file = os.path.join(data_directory, efit_subdir, 'EFITXX.' + str(efit_reconstruction_id) + '.h5')
efit = EFITManager(efit_file, time)
return efit.get_time_sliced_data('output/separatrixGeometry/rmidplaneOut')

Expand All @@ -47,13 +45,14 @@ def plot_attenuation_profile(shot_number, time, radial_coordinate, relative_atte
R_LCFS = get_lcfs_radial_coordinate(shot_number, time)
matplotlib.pyplot.axvline(R_LCFS, c='red', ls='--')
matplotlib.pyplot.text(R_LCFS+0.005, 0.45, 'LCFS', c='red', fontsize=12)
matplotlib.pyplot.savefig(export_directory+'/attenuation.pdf')
matplotlib.pyplot.savefig(export_directory+'/attenuation.svg')
print('Attenuation profile saved as: '+export_directory+'/attenuation.pdf')
matplotlib.pyplot.savefig(os.path.join(export_directory, 'attenuation.pdf'))
matplotlib.pyplot.savefig(os.path.join(export_directory, 'attenuation.svg'))
print('Attenuation profile saved to '+ export_directory)
matplotlib.pyplot.show()


if __name__ == "__main__":
a_shot_number = '17178'
a_time = '1097'
export_beamlet_profile(shot_number=a_shot_number, time=a_time)
a_species = 'Li'
export_beamlet_profile(shot_number=a_shot_number, time=a_time, species=a_species)
2 changes: 1 addition & 1 deletion src/init/structures/beam.cu
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ void init_beam_profile(BeamProfile *device_prof, ShotProp shot){
size_t size_prof = sizeof(BeamProfile);
host_prof = (BeamProfile*)malloc(size_prof);
shared_prof = (BeamProfile*)malloc(size_prof);
init_ion_profile(shot.name, host_prof);
init_ion_profile(shot.long_name, host_prof);
size_t size_rad_prof = sizeof(double)*host_prof->radial_length;
size_t size_cross_prof = sizeof(double)*host_prof->cross_length;

Expand Down
6 changes: 2 additions & 4 deletions src/interface/data_import/beam_renate.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ void load_beam_renate(TaigaGlobals *g, BeamProp *beam, ShotProp *shot, RunProp *
long i, prof_size[2];
long radial_length, cross_length;
double *radial_grid, *radial_profile, *cross_section_grid, *cross_section_profile, speed, ionisation_yeald, xsec_rad, xsec_ang;

char* shotname = concat(shot->shotnumber, "_", shot->time, NULL);


BeamProfile *prof;
size_t size_prof = sizeof(BeamProfile);
prof = (BeamProfile*)malloc(size_prof);
init_ion_profile(shotname, prof);
init_ion_profile(shot->long_name, prof);

speed = calculate_speed(beam->energy, get_mass(beam->species, beam->charge));

Expand Down
2 changes: 2 additions & 0 deletions src/interface/parameter_reader.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ int parameter_reader(BeamProp *beam, ShotProp *shot, RunProp *run){
}
fclose(fp);
strcpy(shot->name, concat(shot->shotnumber, "_", shot->time, NULL));

strcpy(shot->long_name, concat(shot->shotnumber, "_", shot->time, "/", beam->species, "/", to_str(beam->energy), NULL));
strcpy(run->folder_out, concat("results/", shot->shotnumber, "_", shot->time, NULL));
return 0;
}
Expand Down

0 comments on commit 4fc9171

Please sign in to comment.