Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code updates today #1

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions LMI.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
clear all;
close all;
clc;

syms a [9,1];
laminar_state=[1,0,0,0,0,0,0,0,0];
Re_R = [200, 300, 400, 500, 600, 700, 800, 900, 1000, 1500, 2000];


for Re_ind=1:length(Re_R)
Re=Re_R(Re_ind);
Lx = 1.75*pi;
Lz = 1.2*pi;
alpha = (2*pi)/Lx;
Beta = pi/2;
Gamma = 2*pi/Lz;
KBG = sqrt(Beta^2+Gamma^2);
KAG = sqrt(alpha^2+Gamma^2);
KABG = (alpha^2+Beta^2+Gamma^2)^(1/2);

adot(1,1) = Beta^2/Re - Beta^2 * a(1)/Re - sqrt(3/2)*Beta*Gamma*a(6)*a(8)/KABG + sqrt(3/2)*Beta*Gamma*a(2)*a(3)/KBG;
adot(2,1) = -(4*Beta^2/3 + Gamma^2)*a(2)/Re + (5/3)*sqrt(2/3)*Gamma^2*a(4)*a(6)/KAG - Gamma^2*a(5)*a(7)/(sqrt(6)*KAG) ...
- alpha*Beta*Gamma*a(5)*a(8)/(sqrt(6)*KAG*KABG) - sqrt(3/2)*Beta*Gamma*a(1)*a(3)/KBG - sqrt(3/2)*Beta*Gamma*a(3)*a(9)/KBG;
adot(3,1) = -(Beta^2+Gamma^2)*a(3)/Re + 2*alpha*Beta*Gamma*(a(4)*a(7)+a(5)*a(6))/(sqrt(6)*KAG*KBG) + (Beta^2*(3*alpha^2 + Gamma^2) - 3*Gamma^2*(alpha^2 + Gamma^2))*a(4)*a(8)/(sqrt(6)*KAG*KBG*KABG);
adot(4,1) = -(3*alpha^2+4*Beta^2)*a(4)/(3*Re) - alpha*a(1)*a(5)/sqrt(6) - 10*alpha^2*a(2)*a(6)/(3*sqrt(6)*KAG) ...
- sqrt(3/2)*alpha*Beta*Gamma*a(3)*a(7)/KAG*KBG - sqrt(3/2)*alpha^2*Beta^2*a(3)*a(8)/KAG*KBG*KABG - alpha*a(5)*a(9)/sqrt(6);

adot(5,1) = -(alpha^2+Beta^2)*a(5)/Re + alpha*a(1)*a(4)/sqrt(6) + alpha^2*a(2)*a(7)/(sqrt(6)*KAG) - alpha*Beta*Gamma*a(2)*a(8)/(sqrt(6)*KAG*KABG) + alpha*a(4)*a(9)/sqrt(6) + 2*alpha*Beta*Gamma*a(3)*a(6)/(sqrt(6)*KAG*KBG);

adot(6,1) = -(3*alpha^2+4*Beta^2+3*Gamma^2)*a(6)/(3*Re) + alpha*a(1)*a(7)/sqrt(6) + sqrt(3/2)*Beta*Gamma*a(1)*a(8)/KABG ...
+ 10*(alpha^2-Gamma^2)*a(2)*a(4)/(KAG*3*sqrt(6)) - 2*sqrt(2/3)*a(3)*a(5)*alpha*Beta*Gamma/(KAG*KBG) + alpha*a(7)*a(9)/sqrt(6) + sqrt(3/2)*Beta*Gamma*a(8)*a(9)/KABG ;

adot(7,1) = -(alpha^2+Beta^2+Gamma^2)*a(7)/Re - alpha*(a(1)*a(6)+ a(6)*a(9))/sqrt(6) + (Gamma^2- alpha^2)*a(2)*a(5)/(sqrt(6)*KAG) + alpha*Beta*Gamma*a(3)*a(4)/(sqrt(6)*KAG*KBG);

adot(8,1) = -(alpha^2+Beta^2+Gamma^2)*a(8)/Re + 2*alpha*Beta*Gamma*a(2)*a(5)/(sqrt(6)*KAG*KABG) + Gamma^2*(3*alpha^2-Beta^2+3*Gamma^2)*a(3)*a(4)/(sqrt(6)*KAG*KBG*KABG);

adot(9,1) = -9*Beta^2*a(9)/Re +sqrt(3/2)*Beta*Gamma*a(2)*a(3)/KBG -sqrt(3/2)*Beta*Gamma*a(6)*a(8)/KABG;


end
adot_jacobian=jacobian(adot);
% adot_hessian=hessian(adot,a);

15 changes: 10 additions & 5 deletions ODE45_9D_model.m
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@

%y0 = [0,0,0,0,0,0,0,0,0]; % 9d model %
num_vectors = 10000; %should be large enough
num_vectors = 10; %should be large enough
Re_R = [200, 300, 400, 500, 600, 700, 800, 900, 1000, 1500, 2000];
min_distances = zeros(size(Re_R));
laminar_state=[1,0,0,0,0,0,0,0,0];
delta_list=logspace(-5,-1,100); %the last value of logspace means spacing should also be large enough
parfor i = 1:length(Re_R)
delta_list=logspace(-5,-1,128); %the last value of logspace means spacing should also be large enough
delete(gcp('nocreate'));
parpool(64);
for i = 1:length(Re_R)
Re = Re_R(i);
distances = zeros(1, num_vectors);
laminar_delta_ind=zeros(size(delta_list));
for delta_ind=1:length(delta_list)
parfor delta_ind=1:length(delta_list)
distances = zeros(1, num_vectors);
delta=delta_list(delta_ind);
for j = 1:num_vectors
perturbation=randn(1,9);
Expand All @@ -26,11 +28,14 @@
min_distances(i) = max(laminar_delta_ind.*delta_list);
end

save('ODE45_9D_model.mat');

loglog(Re_R, min_distances, '-o')
xlabel('Re')
ylabel('Minimum boundary distance')
title('Minimum boundary distance vs Reynolds number')
grid on
saveas(gcf,'figure.fig');



Expand Down
30 changes: 16 additions & 14 deletions SLURM
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
#!/bin/bash
#SBATCH -p general # --partition, selecting a partition
#SBATCH -C epyc128 # --constraint, want an Epyc 128-core node
#SBATCH -c 126 # --cpus-per-task, 126 cores will be used per task
#SBATCH -n 1 # --ntasks, # tasks in this batch job
#SBATCH -N 1 # --nnodes, all 126 cores to come from 1 node
#!/bin/bash -l
#SBATCH --job-name=matlab
#SBATCH --time=01:00:00
#SBATCH --partition=general
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=64
#SBATCH --output=matlab_history_%j

#SBATCH --partition=general # Name of partition
#SBATCH --ntasks=48 # Request 48 CPU cores
#SBATCH --time=02:00:00 # Job should run for up to 2 hours
#SBATCH --mail-type=END # Event(s) that triggers email notification (BEGIN,END,FAIL,ALL)
#SBATCH [email protected] # Destination email address
#---------------------------------------------------------------------
# SLURM job script to run serial MATLAB
#---------------------------------------------------------------------

module load matlab
SUBMITDIR=$SLURM_SUBMIT_DIR
WORKDIR=/scratch/zhw22003/zhw22003/matlab_$SLURM_JOB_ID
mkdir -p "$WORKDIR" && cp -r *.m "$WORKDIR" && cp submit_* "$WORKDIR" && cd "$WORKDIR" || exit -1

matlab -nodisplay -r "run('run_ode45_parallel.m'); exit;"
module load matlab/R2022a

bash my_script.sh
matlab -nodisplay -nosplash -nodesktop -r "ODE45_9D_model"

echo "matlab exit code: $?"
28 changes: 28 additions & 0 deletions submit_matlab_uconn
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash -l
#SBATCH --job-name=matlab
#SBATCH --time=01:00:00
###SBATCH --partition=general
###SBATCH --partition=lo-core # This can be as long as 7 days
#SBATCH --partition=priority # This can run infinite time with priority in queue
#SBATCH --account=chl23026
#SBATCH --qos=chl23026
#SBATCH --constraint=epyc128 # This is optional
###SBATCH --mem=16G
###SBATCH --no-requeue
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=64
#SBATCH --output=matlab_history_%j

#---------------------------------------------------------------------
# SLURM job script to run serial MATLAB
#---------------------------------------------------------------------

SUBMITDIR=$SLURM_SUBMIT_DIR
WORKDIR=/scratch/chl23026/chl23026/matlab_$SLURM_JOB_ID
mkdir -p "$WORKDIR" && cp -r *.m "$WORKDIR" && cp submit_* "$WORKDIR" && cd "$WORKDIR" || exit -1

module load matlab/R2022b

matlab -nodisplay -nosplash -nodesktop -r "ODE45_9D_model"

echo "matlab exit code: $?"