addBracket.py
import re
import os
cwdPath = os.getcwd()
print('Current directory is: ', cwdPath)
file_name_list = os.listdir(cwdPath)
print('Files\' names are: ', file_name_list)
reCom = re.compile(".*\.txt")
file_read_list = []
for file_name in file_name_list:
is_match = reCom.match(file_name)
if is_match:
file_read_list.append(file_name)
print('Files to read are: ', file_read_list)
for fileread in file_read_list:
filewrite = fileread + '.out'
frd = open(fileread, 'r')
GsPt_num = re.findall(r"\d+", fileread)
GsPt_num = GsPt_num[1]
print('number of gauss points is: ', GsPt_num)
sth = frd.readlines()
GsPt_num_file = re.findall(r"\d+", sth[0])
GsPt_num_file = GsPt_num_file[0]
print('number of gauss points in file to read is: ', GsPt_num_file)
if GsPt_num == GsPt_num_file:
ifModify = 0
else:
ifModify = 1
if ifModify:
fwt = open(filewrite, 'w')
print('Number of Gauss Points is: ', sth.__len__())
print('type of sth[0] is: ', type(sth[0]))
sthRe = re.findall(r"\d+\.?\d*", sth[0])
print('Number of scalar in each Gauss Point: ', sthRe.__len__())
print('Type of sthRe[0] is: ', type(sthRe[0]))
fwt.write(str(sth.__len__()) + ' ' + str(sthRe.__len__()) + "\n(\n")
for oneLine in sth:
outLine = '(' + oneLine[1:oneLine.__len__() - 1] + ')\n'
fwt.write(outLine)
fwt.write(')\n')
frd.close()
fwt.close()
os.remove(fileread)
os.rename(filewrite, fileread)
else:
frd.close()
plotCMZ.m
clearvars; clc; % plotCMZ.m
inter_raw_data_CMZ=importdata("rawData\t_vs_cm_inter.csv");
tmp_1=zeros(size(inter_raw_data_CMZ,1),1);
for ii=1:size(inter_raw_data_CMZ,1)
tmp_2=inter_raw_data_CMZ(ii,:);
tmp_2=cell2mat(tmp_2);
tmp_2=convertCharsToStrings(tmp_2);
tmp_2=strsplit(tmp_2,'\t');
tmp_2=str2double(tmp_2(1:1));
tmp_1(ii,1)=tmp_2;
end
tmp_1=unique(tmp_1);
inter_CMZ=zeros(size(tmp_1,1),4);
for ii=1:size(tmp_1,1)
tmp_2=inter_raw_data_CMZ(ii,:);
tmp_2=cell2mat(tmp_2);
tmp_2=convertCharsToStrings(tmp_2);
tmp_2=strsplit(tmp_2,' ');
tmp_2=tmp_2(1,2:size(tmp_2,2));
tmp_2=str2double(tmp_2);
inter_CMZ(ii,1)=tmp_1(ii,1);
inter_CMZ(ii,2)=tmp_2(1,1);
inter_CMZ(ii,3)=tmp_2(1,2);
inter_CMZ(ii,4)=tmp_2(1,3);
end
clear inter_raw_data_CMZ tmp_2 tmp_1 ii;
inter_raw_data_CMZ=importdata("rawData\t_vs_cm_over.csv");
tmp_1=zeros(size(inter_raw_data_CMZ,1),1);
for ii=1:size(inter_raw_data_CMZ,1)
tmp_2=inter_raw_data_CMZ(ii,:);
tmp_2=cell2mat(tmp_2);
tmp_2=convertCharsToStrings(tmp_2);
tmp_2=strsplit(tmp_2,'\t');
tmp_2=str2double(tmp_2(1:1));
tmp_1(ii,1)=tmp_2;
end
tmp_1=unique(tmp_1);
over_CMZ=zeros(size(tmp_1,1),4);
for ii=1:size(tmp_1,1)
tmp_2=inter_raw_data_CMZ(ii,:);
tmp_2=cell2mat(tmp_2);
tmp_2=convertCharsToStrings(tmp_2);
tmp_2=strsplit(tmp_2,' ');
tmp_2=tmp_2(1,2:size(tmp_2,2));
tmp_2=str2double(tmp_2);
over_CMZ(ii,1)=tmp_1(ii,1);
over_CMZ(ii,2)=tmp_2(1,1);
over_CMZ(ii,3)=tmp_2(1,2);
over_CMZ(ii,4)=tmp_2(1,3);
end
clear inter_raw_data_CMZ tmp_2 tmp_1 ii;
inter_raw_data_CMZ=importdata("rawData\t_vs_cm_thinc.csv");
tmp_1=zeros(size(inter_raw_data_CMZ,1),1);
for ii=1:size(inter_raw_data_CMZ,1)
tmp_2=inter_raw_data_CMZ(ii,:);
tmp_2=cell2mat(tmp_2);
tmp_2=convertCharsToStrings(tmp_2);
tmp_2=strsplit(tmp_2,'\t');
tmp_2=str2double(tmp_2(1:1));
tmp_1(ii,1)=tmp_2;
end
tmp_1=unique(tmp_1);
thincp_CMZ=zeros(size(tmp_1,1),4);
for ii=1:size(tmp_1,1)
tmp_2=inter_raw_data_CMZ(ii,:);
tmp_2=cell2mat(tmp_2);
tmp_2=convertCharsToStrings(tmp_2);
tmp_2=strsplit(tmp_2,' ');
tmp_2=tmp_2(1,2:size(tmp_2,2));
tmp_2=str2double(tmp_2);
thincp_CMZ(ii,1)=tmp_1(ii,1);
thincp_CMZ(ii,2)=tmp_2(1,1);
thincp_CMZ(ii,3)=tmp_2(1,2);
thincp_CMZ(ii,4)=tmp_2(1,3);
end
clear inter_raw_data_CMZ tmp_2 tmp_1 ii;
inter_raw_data_CMZ=importdata("rawData\t_vs_cm_overThinc.csv");
tmp_1=zeros(size(inter_raw_data_CMZ,1),1);
for ii=1:size(inter_raw_data_CMZ,1)
tmp_2=inter_raw_data_CMZ(ii,:);
tmp_2=cell2mat(tmp_2);
tmp_2=convertCharsToStrings(tmp_2);
tmp_2=strsplit(tmp_2,'\t');
tmp_2=str2double(tmp_2(1:1));
tmp_1(ii,1)=tmp_2;
end
tmp_1=unique(tmp_1);
overThinc_CMZ=zeros(size(tmp_1,1),4);
for ii=1:size(tmp_1,1)
tmp_2=inter_raw_data_CMZ(ii,:);
tmp_2=cell2mat(tmp_2);
tmp_2=convertCharsToStrings(tmp_2);
tmp_2=strsplit(tmp_2,' ');
tmp_2=tmp_2(1,2:size(tmp_2,2));
tmp_2=str2double(tmp_2);
overThinc_CMZ(ii,1)=tmp_1(ii,1);
overThinc_CMZ(ii,2)=tmp_2(1,1);
overThinc_CMZ(ii,3)=tmp_2(1,2);
overThinc_CMZ(ii,4)=tmp_2(1,3);
end
clear inter_raw_data_CMZ tmp_2 tmp_1 ii;
inter_raw_data_CMZ=importdata("rawData\t_vs_cm_thincRK2.csv");
tmp_1=zeros(size(inter_raw_data_CMZ,1),1);
for ii=1:size(inter_raw_data_CMZ,1)
tmp_2=inter_raw_data_CMZ(ii,:);
tmp_2=tmp_2(1:1);
tmp_1(ii,1)=tmp_2;
end
tmp_1=unique(tmp_1);
thincr_CMZ=zeros(size(tmp_1,1),4);
for ii=1:size(tmp_1,1)
tmp_2=inter_raw_data_CMZ(ii,:);
tmp_2=tmp_2(1,2:size(tmp_2,2));
thincr_CMZ(ii,1)=tmp_1(ii,1);
thincr_CMZ(ii,2)=tmp_2(1,1);
thincr_CMZ(ii,3)=tmp_2(1,2);
thincr_CMZ(ii,4)=tmp_2(1,3);
end
clear inter_raw_data_CMZ tmp_2 tmp_1 ii;
%
% inter_raw_data_CMZ=importdata("rawData\t_vs_cm_thincRK2.csv");
% tmp_1=zeros(size(inter_raw_data_CMZ,1),1);
% tmp_3=zeros(size(inter_raw_data_CMZ,1),1);
% for ii=1:size(inter_raw_data_CMZ,1)
% tmp_2=inter_raw_data_CMZ(ii,:);
% tmp_2=cell2mat(tmp_2);
% tmp_2=convertCharsToStrings(tmp_2);
% tmp_2=strsplit(tmp_2,'\t');
% tmp_2=str2double(tmp_2(1:1));
% tmp_1(ii,1)=tmp_2;
% tmp_4=inter_raw_data_CMZ(ii,:);
% tmp_4=cell2mat(tmp_4);
% tmp_4=convertCharsToStrings(tmp_4);
% tmp_4=strsplit(tmp_4,' ');
% if (size(tmp_4,2)<2)
% break;
% else
% tmp_4=tmp_4(1,size(tmp_4,2));
% end
% tmp_3(ii,1)=str2double(tmp_4);
% end
% tmp_1=unique(tmp_1);
% tmp_1=tmp_1(2:size(tmp_1,1),:);
% indexJJ=0;
% for ii=1:size(tmp_3,1)
% if (tmp_3(ii,1)<0.01)
% break;
% else
% indexJJ=indexJJ+1;
% end
% end
% tmp_3=tmp_3(1:indexJJ,:);
% tmp_5=zeros(round(size(tmp_3,1)/2),1);
% for ii=1:size(tmp_5,1)
% tmp_5(ii,1)=(tmp_3(2*ii,1)+tmp_3(2*ii-1,1))/2;
% end
% thincr_CMZ=zeros(size(tmp_1,1),4);
% for ii=1:size(tmp_1,1)
% tmp_2=inter_raw_data_CMZ(ii,:);
% tmp_2=cell2mat(tmp_2);
% tmp_2=convertCharsToStrings(tmp_2);
% tmp_2=strsplit(tmp_2,' ');
% tmp_2=tmp_2(1,2:size(tmp_2,2));
% tmp_2=str2double(tmp_2);
% thincr_CMZ(ii,1)=tmp_1(ii,1);
% thincr_CMZ(ii,2)=tmp_2(1,1);
% thincr_CMZ(ii,3)=tmp_2(1,2);
% thincr_CMZ(ii,4)=tmp_5(ii,1);
% end
% clear inter_raw_data_CMZ tmp_2 tmp_1 ii tmp_3 tmp_4 tmp_5;
fig1=figure(1);
% x_to_plot=inter_CMZ(:,1); y_to_plot=inter_CMZ(:,4);
% plt1=plot(x_to_plot,y_to_plot);plt1.LineWidth=1.5;plt1.Color='blue';hold on;
% x_to_plot=over_CMZ(:,1); y_to_plot=over_CMZ(:,4);
% plt2=plot(x_to_plot,y_to_plot);plt2.LineWidth=1.5;plt2.Color='red';hold on;
x_to_plot=thincp_CMZ(:,1); y_to_plot=thincp_CMZ(:,4);
plt3=plot(x_to_plot,y_to_plot);plt3.LineWidth=1.5;plt3.Color='magenta';hold on;
x_to_plot=thincr_CMZ(:,1); y_to_plot=thincr_CMZ(:,4);
plt4=plot(x_to_plot,y_to_plot);plt4.LineWidth=1.5;plt4.Color='black';hold on;
x_to_plot=overThinc_CMZ(:,1); y_to_plot=overThinc_CMZ(:,4);
plt5=plot(x_to_plot,y_to_plot);plt5.LineWidth=1.5;plt5.Color='green';hold on;
xL1=xlabel('time (s)'); xL1.FontSize=15; yL1=ylabel('Height (m)'); yL1.FontSize=15;
% leg1=legend(); leg1.FontSize=17; leg1.String=["inter","overInter","thinc-p","thinc-RK2","overThinc"];
leg1=legend([plt3,plt4,plt5]); leg1.FontSize=17; leg1.String=["thinc-CN","thinc-RK2","overThinc"];
saveas(gcf,"image\poltCMZ.png");
plotFy.m
clearvars; clc; % plotFy.m
inter_raw_data_Fy=importdata("rawData\wedge\t_Fy_inter.csv");
zhao_raw_data_Fy=importdata("rawData\wedge\zhao_wedgeFy.csv");
jin_num_data_Fy=importdata("rawData\wedge\jin_num_Fy.csv");
zhao_num_data_Fy=importdata("rawData\wedge\zhao_num_Fy.csv");
thinc_raw_data_Fy=importdata("rawData\wedge\t_Fy_thinc.csv");
inter_raw_data_Fy=inter_raw_data_Fy.data; thinc_raw_data_Fy=thinc_raw_data_Fy.data;
tmp_1=zeros(size(thinc_raw_data_Fy,1),1);
for ii=1:(size(tmp_1,1)-1)
tmp_3=thinc_raw_data_Fy(ii+1,2); tmp_2=thinc_raw_data_Fy(ii,2);
bond=50;
if(abs(tmp_3-tmp_2)>bond)
thinc_raw_data_Fy(ii+1,2)=tmp_2+(tmp_3-tmp_2)/(abs(tmp_3-tmp_2))*bond;
end
end
clear tmp_1 tmp_2 tmp_3;
fig1=figure(1); set(gca,'ylim',[0,8000]);hold on;
x_to_plot=inter_raw_data_Fy(:,1); y_to_plot=inter_raw_data_Fy(:,2).*0.25;
plt1=plot(x_to_plot,y_to_plot); plt1.Color='blue'; plt1.LineWidth=2.0; hold on;
x_to_plot=zhao_raw_data_Fy(:,1); y_to_plot=zhao_raw_data_Fy(:,2);
sc1=scatter(x_to_plot,y_to_plot); sc1.Marker='s'; sc1.MarkerFaceColor='Black'; sc1.SizeData=80; hold on;
x_to_plot=zhao_num_data_Fy(:,1); y_to_plot=zhao_num_data_Fy(:,2);
plt2=plot(x_to_plot,y_to_plot); plt2.Color='Black'; plt2.LineWidth=2.0; plt2.LineStyle='--'; hold on;
x_to_plot=jin_num_data_Fy(:,1); y_to_plot=jin_num_data_Fy(:,2);
plt3=plot(x_to_plot,y_to_plot); plt3.Color='green'; plt3.LineWidth=2.0; plt3.LineStyle='-'; hold on;
x_to_plot=thinc_raw_data_Fy(:,1); y_to_plot=thinc_raw_data_Fy(:,2).*0.25;
plt4=plot(x_to_plot,y_to_plot); plt4.Color='red'; plt4.LineWidth=2.0; hold on;
leg1=legend([sc1,plt1,plt2,plt3,plt4]); leg1.FontSize=15; leg1.String=["Exp(Zhao)","inter","Num(Zhao)","Num(Jin)","thinc"]; leg1.Location='south';
xL1=xlabel('time (s)'); xL1.FontSize=15; yL1=ylabel('Vertical Force (N)'); yL1.FontSize=15;
saveas(gcf,"image\wedge\plotFy.png");
plotVY.m
clearvars; clc; % plotVY.m
zhao_raw_data_VY=importdata("rawData\wedge\zhao_wedgeVY.csv");
inter_raw_data_VY=importdata("rawData\wedge\t_lv_inter.csv");
inter_t_lv=zeros(size(inter_raw_data_VY,1),2);
tmp_1=zeros(size(inter_raw_data_VY,1),1);
tmp_dt=zeros(size(inter_raw_data_VY,1)-1,1);
for ii=1:size(tmp_1,1)
tmp_2=inter_raw_data_VY(ii,1);
tmp_2=cell2mat(tmp_2);
tmp_2=convertCharsToStrings(tmp_2);
tmp_2=strsplit(tmp_2,'\t');
tmp_3=str2double(tmp_2(1,1));
tmp_2=tmp_2(1,2);
tmp_2=strsplit(tmp_2,' ');
tmp_2=tmp_2(1,3);
tmp_2=str2double(tmp_2);
tmp_1(ii,1)=tmp_3;
inter_t_lv(ii,1)=tmp_1(ii,1);
inter_t_lv(ii,2)=-tmp_2;
end
for ii=1:size(tmp_dt,1)
tmp_dt(ii)=tmp_1(ii+1,1)-tmp_1(ii,1);
end
clear tmp_1 tmp_2 tmp_3 ii inter_raw_data_VY tmp_dt;
thinc_raw_data_VY=importdata("rawData\wedge\t_lv_thinc.csv");
thinc_t_lv=zeros(size(thinc_raw_data_VY,1),2);
tmp_1=zeros(size(thinc_raw_data_VY,1),1);
tmp_dt=zeros(size(thinc_raw_data_VY,1)-1,1);
for ii=1:size(tmp_1,1)
tmp_2=thinc_raw_data_VY(ii,:);
tmp_2=cell2mat(tmp_2);
tmp_2=convertCharsToStrings(tmp_2);
tmp_2=strsplit(tmp_2,'\t');
tmp_3=str2double(tmp_2(1,1));
tmp_2=tmp_2(1,2);
tmp_2=strsplit(tmp_2,' ');
tmp_2=tmp_2(1,3);
tmp_2=str2double(tmp_2);
tmp_1(ii,1)=tmp_3;
thinc_t_lv(ii,1)=tmp_1(ii,1);
thinc_t_lv(ii,2)=-tmp_2;
end
for ii=1:size(tmp_dt,1)
tmp_dt(ii)=tmp_1(ii+1,1)-tmp_1(ii,1);
end
dt_min=min(tmp_dt);
clear tmp_1 tmp_2 tmp_3 ii thinc_raw_data_VY tmp_dt;
fig1=figure(1); hold on;
x_to_plot=zhao_raw_data_VY(:,1); y_to_plot=zhao_raw_data_VY(:,2);
sc1=scatter(x_to_plot,y_to_plot); sc1.Marker='s'; sc1.MarkerFaceColor='Black'; sc1.SizeData=80; hold on;
x_to_plot=inter_t_lv(:,1); y_to_plot=inter_t_lv(:,2);
plt1=plot(x_to_plot,y_to_plot); plt1.Color='blue'; plt1.LineWidth=2.0; hold on;
x_to_plot=thinc_t_lv(:,1); y_to_plot=thinc_t_lv(:,2);
plt2=plot(x_to_plot,y_to_plot); plt2.Color='red'; plt2.LineWidth=2.0; hold on;
leg1=legend([sc1,plt1,plt2]);
leg1.FontSize=17; leg1.String=["Exp (Zhao)","inter","thinc"];
xL1=xlabel('time (s)'); xL1.FontSize=15; yL1=ylabel('Vertical Velocity (m/s)'); yL1.FontSize=15;
saveas(gcf,"image\wedge\plotVY.png");