Skip to content

Commit

Permalink
Reduce MATLAB boilerplate: PART V
Browse files Browse the repository at this point in the history
Issue #2 touches the MF-running scripts [+ polish on DMFT-SLURM scripts]

Some bugs have been fixed at beddalumia/QcmP-LAB@856ab5e and now we can say that every MF script runs smoothly (single-line, full-diagram, phase maps, energy surfaces!)

---------

We are ready to attack the nasty plotting scripts now (by extending the +plotDMFT package within DMFT-LAB) 🚀
  • Loading branch information
beddalumia committed Jan 13, 2022
1 parent 72d9cdb commit c0a9410
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 171 deletions.
10 changes: 5 additions & 5 deletions KMH-DMFT/KMH-DMFT_hpc/full-mpi_single-line_matjob.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ cd $SLURM_SUBMIT_DIR # Brings the shell into the directory from which you’ve s
# Just fill this part as if it was a regular Bash script that you want to
# run on your computer.
#
# >> DMFT-Workflow (uncomment just one of these...)
matlab -batch "runDMFT.dry_line('ed_kane_mele',true,-1,0,0.5,8,'t2',0.1)"
matlab -batch "runDMFT.autostop_line('ed_kane_mele',true,-1,0,0.5,8,'t2',0.1)"
matlab -batch "runDMFT.autostep_line('ed_kane_mele',true,-1,0,8,'t2',0.1)"
matlab -batch RunningDMFT_refresh # runDMFT.refresh_line() in progress...
# >> DMFT-Workflow (fill and uncomment just one of these...)
#matlab -batch "runDMFT.dry_line('ed_kane_mele',doMPI,Uold,Umin,Ustep,Umax,'t2',SOI)"
#matlab -batch "runDMFT.autostop_line('ed_kane_mele',doMPI,Uold,Umin,Ustep,Umax,'t2',SOI)"
#matlab -batch "runDMFT.autostep_line('ed_kane_mele',doMPI,Uold,Umin,Umax,'t2',SOI)"
#matlab -batch RunningDMFT_refresh # runDMFT.refresh_line() in progress...
#
#
# ==== END OF JOB COMMANDS ===== #
Expand Down
10 changes: 5 additions & 5 deletions KMH-DMFT/KMH-DMFT_hpc/mpi-serial_single-line_matjob.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ cd $SLURM_SUBMIT_DIR # Brings the shell into the directory from which you’ve s
# Just fill this part as if it was a regular Bash script that you want to
# run on your computer.
#
# >> DMFT-Workflow (uncomment just one of these...)
matlab -batch "runDMFT.dry_line('ed_kane_mele',true,-1,0,0.5,8,'t2',0.1)"
matlab -batch "runDMFT.autostop_line('ed_kane_mele',true,-1,0,0.5,8,'t2',0.1)"
matlab -batch "runDMFT.autostep_line('ed_kane_mele',true,-1,0,8,'t2',0.1)"
matlab -batch RunningDMFT_refresh # runDMFT.refresh_line() in progress...
# >> DMFT-Workflow (fill and uncomment just one of these...)
#matlab -batch "runDMFT.dry_line('ed_kane_mele',doMPI,Uold,Umin,Ustep,Umax,'t2',SOI)"
#matlab -batch "runDMFT.autostop_line('ed_kane_mele',doMPI,Uold,Umin,Ustep,Umax,'t2',SOI)"
#matlab -batch "runDMFT.autostep_line('ed_kane_mele',doMPI,Uold,Umin,Umax,'t2',SOI)"
#matlab -batch RunningDMFT_refresh # runDMFT.refresh_line() in progress...
#
#
# ==== END OF JOB COMMANDS ===== #
Expand Down
112 changes: 18 additions & 94 deletions KMH-MF/KMH-MF_mat/DryMF_grid.m
Original file line number Diff line number Diff line change
@@ -1,108 +1,32 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% HOW TO USE?
%
% - Put this script, together with an input-file for your model, in a path
% > This path will contain directories for all the U values you set-up.
% - Set-up the name of your driver program (without .f90 extension)
% > e.g. driver = 'ed_kane_mele';
% - Adjust Umin, Umax and Ustep to your desire --> U = Umin:Ustep:Umax
% - Set SOI to your desire: --> you will get a fixed-SOI linear span
% - Adjust Uold to catch a 'restart-folder' in the path [!applies -> -1]
% - Select doMPI (true.or.false) to run with openMPI or not
% - Run everything with $ matlab -batch DryMF_line
% - At the end you will find some additional output in the U=%f folders
% > a LOG_mf.txt which is just a mirror of the MF output (via tee)
% > a LOG_time.txt which is a wall-clock-time value for the whole MF
% - Also an additional output file in the main (external) path
% > a U_list.txt that stores all the used U-values (for easier post..)
% NB. Only the converged calculations will update the U_list :D
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

driver = 'mf_km_2d'; doMPI = true;

% Let MATLAB see the goddamn PATH %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% -> works only if matlab has been started from a unix terminal! (0^0~~,)
path = getenv('PATH');
path = [path ':/usr/local/bin'];
setenv('PATH', path)
clear path
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Ulist = fopen('U_list.txt','a');

%% SOC-Line: outer loop %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
driver = 'mf_km_2d';
doMPI = false; % >> MF-code is not MPI-safe <<

spin_orbit = [0,0.02,0.04,0.06,0.08,0.1,0.2,0.3];
Nsoi = length(spin_orbit);
for iSOI = 1:Nsoi % Spin-Orbit loop =========================>
Nopms = 4; % #{order parameters}

SOI = spin_orbit(iSOI); % Input Spin-Orbit
%% SOC-Line: outer loop %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for iSOI = 1:Nsoi

soiDIR= sprintf('SOI=%f',SOI); % Make a folder named 'SOI=...', where '...'
mkdir(soiDIR); % is the given value for SpinOrb interaction
cd(soiDIR); % Enter the SOI-folder
SOI = spin_orbit(iSOI); % Input Spin-Orbit

copyfile ../input* % Copy inside the **external** input file
soiDIR= sprintf('SOI=%f',SOI); % Make a folder named 'SOI=...', where '...'
mkdir(soiDIR); % is the given value for SpinOrb interaction
cd(soiDIR); % Enter the SOI-folder

%% Phase-Line: inner loop %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
copyfile ../input* % Copy inside the **external** input file

Umin = 0; Umax = 8; % Input Hubbard
Ustep = 0.1; % Phase-line step
Uold = -1; % Restart option
%% Phase-Line: inner loop %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

U = Umin;
while U <= Umax % Hubbard loop ~~~~~~~~~~~~~~~~~~~~~~~~~~~>
Uold = NaN; % Restart point
Umin = 0.00; % Phase-line start
Ustep = 0.25; % Phase-line step
Umax = 8.00; % Phase-line end

UDIR= sprintf('U=%f',U); % Make a folder named 'U=...', where '...'
mkdir(UDIR); % is the given value for Hubbard interaction
cd(UDIR); % Enter the U-folder
runDMFT.dry_line(driver,doMPI,Uold,Umin,Ustep,Umax,'t2',SOI,'nparams',Nopms);

oldDIR=sprintf('../U=%f',Uold); % ------------------------------------
if isfolder(oldDIR) % If it exist a "previous" folder:
restartpack = [oldDIR,'/*.restart']; % Copy all the restart files from the
copyfile(restartpack); % last mf evaluation...
end % ------------------------------------
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

copyfile ../input* % Copy inside the **external** input file
cd .. % Exit the SOI-folder

%% Run FORTRAN code (already compiled and added to PATH!) %%%%%%%%%%%%%%%%%
if doMPI
mpi = 'mpirun '; % Control of MPI
else % boolean flag...
mpi = [];
end
HUBBARD =sprintf(' uloc=%f',U); % OVERRIDE of
T2 =sprintf(' t2=%f',SOI); % PARAMETERS
outLOG = ' > LOG.mf';
mf_call = [mpi,driver,HUBBARD,T2,outLOG];
tic
system(mf_call); % Fortran-call
chrono = toc;
file_id = fopen('LOG_time.txt','w'); % Write on time-log
fprintf(file_id,'%f\n', chrono);
fclose(file_id);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% HERE WE CATCH A FAILED (unconverged) MF LOOP
if ~isfile('ERROR.README')
fprintf(Ulist,'%f\n', U); % Update U-list (only if converged)
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

cd .. % Exit the U-folder

Uold = U;
U = U + Ustep; % Hubbard update

end % <~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

cd .. % Exit the SOI-folder

end % <=========================================

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

fclose(Ulist);

77 changes: 10 additions & 67 deletions KMH-MF/KMH-MF_mat/DryMF_line.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
% - Put this script, together with an input-file for your model, in a path
% > This path will contain directories for all the U values you set-up.
% - Set-up the name of your driver program (without .f90 extension)
% > e.g. driver = 'ed_kane_mele';
% > e.g. driver = 'mf_km_2d';
% - Adjust Umin, Umax and Ustep to your desire --> U = Umin:Ustep:Umax
% - Set SOI to your desire: --> you will get a fixed-SOI linear span
% - Adjust Uold to catch a 'restart-folder' in the path [!applies -> -1]
Expand All @@ -19,71 +19,14 @@
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

driver = 'mf_km_2d'; doMPI = true;
driver = 'mf_km_2d';
doMPI = false; % >> MF-code is not MPI-safe <<

% Let MATLAB see the goddamn PATH %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% -> works only if matlab has been started from a unix terminal! (0^0~~,)
path = getenv('PATH');
path = [path ':/usr/local/bin'];
setenv('PATH', path)
clear path
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Ulist = fopen('U_list.txt','a');

%% Phase-Line: single loop %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

SOI = 0; % Input Spin-Orbit
Umin = 2.05; Umax = 4; % Input Hubbard
Ustep = 0.05; % Phase-line step
Uold = 2; % Restart option

U = Umin;
while U <= Umax % Hubbard loop ~~~~~~~~~~~~~~~~~~~~~~~~~~~>

UDIR= sprintf('U=%f',U); % Make a folder named 'U=...', where '...'
mkdir(UDIR); % is the given value for Hubbard interaction
cd(UDIR); % Enter the U-folder

oldDIR=sprintf('../U=%f',Uold); % ------------------------------------
if isfolder(oldDIR) % If it exist a "previous" folder:
restartpack = [oldDIR,'/*.restart']; % Copy all the restart files from the
copyfile(restartpack); % last mf evaluation...
end % ------------------------------------

copyfile ../input* % Copy inside the **external** input file

%% Run FORTRAN code (already compiled and added to PATH!) %%%%%%%%%%%%%%%%%
if doMPI
mpi = 'mpirun '; % Control of MPI
else % boolean flag...
mpi = [];
end
HUBBARD =sprintf(' uloc=%f',U); % OVERRIDE of
T2 =sprintf(' t2=%f',SOI); % PARAMETERS
outLOG = ' > LOG.out';
mf_call = [mpi,driver,HUBBARD,T2,outLOG];
tic
system(mf_call); % Fortran-call
chrono = toc;
file_id = fopen('LOG_time.txt','w'); % Write on time-log
fprintf(file_id,'%f\n', chrono);
fclose(file_id);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% HERE WE CATCH A FAILED (unconverged) MF LOOP
if ~isfile('ERROR.README')
fprintf(Ulist,'%f\n', U); % Update U-list (only if converged)
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

cd .. % Exit the U-folder

Uold = U;
U = U + Ustep; % Hubbard update

end % <~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

fclose(Ulist);
SOI = 0.00; % Fixed Spin-Orbit
Uold = 2.00; % Restart point
Umin = 2.05; % Phase-line start
Ustep = 0.05; % Phase-line step
Umax = 4.00; % Phase-line end
Nopms = 4; % #{order parameters}

runDMFT.dry_line(driver,doMPI,Uold,Umin,Ustep,Umax,'t2',SOI,'nparams',Nopms);

0 comments on commit c0a9410

Please sign in to comment.