clear all;
close all;
clc;
format long;
%% -------------------------POLARASE-----------------------------------
%-------------developed by Cui-Lan Ren and Ju Li----------------------
%-------------------------Main program-----------------------------------
%----------------------------Dec.2019--------------------------------------
% The POLARASE aims to provide a machine learning guided
% sample spinning strategy (SSS) to mitigate polarization artifact 
% and interstitial-vacancy imbalance in ion irradiation
%
% Case study: Self-ion irradiation in iron with energy 5 MeV
% Note: each subroutine can be run independently.
% -----------------------------------------------------------------------------
fprintf('%s','POLAEASE starts')
tic
%% Data generation: vacancy / interstitial / I-V excess concentration 
% Database: Primary radiation damages (PRDs) calculated by IM3D with "FC" options
% Self-irradiation in iron with E0=5.0 MeV
% Theta (oblique angle) =0~pi/2 with  90 point sampling

Data_gen;

%% Neural network (NN) training on Excess
% Machine learning NN-trained model of Excess in ion momentum space

Exc_NNtraining;

%% Neural network (NN) training on Excess
% Similar to above NN surrogate model of Excess, 
% NN-trained model of damage in ion momentum space

Dam_NNtraining;

%% SSS subroutine 
% Ion momentum mixing based on SSS framework, 
% Ion momentum (E,¦È) status respect to the target during the rotation 
% is determined by surface inclination angle (¦È0), and rotation axis (¦È1,¦È2) 
% Evaluate the figure of merit for every grid of (¦È0,¦È1,¦È2)
% Note: we use (q0,q1,q2)  in POLARASE code for the sake of simplicity 

SSS;

%% Results outputs 
% Figure outputs for the case study
% Self-ion irradiation in iron with energy 5 MeV
% The I-V excesses are reduced significantly
% with quasi-flat damage in the same depth region

Display; 

%% ---------------------------------------------------------------------
fprintf('%s','The POLAEASE is done')
%
toc
