-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSHPB_main.m
151 lines (114 loc) · 3.97 KB
/
SHPB_main.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
% function [strain, stress_out, stress_in, e_rate] = SHPB_main
clc
clear all
close all
hold on
global signal distance_in distance_ref distance_out C0 a amp Ebar Values Asample f_cutt v iter
data_dir = './';
vel = 'sample_data.dat';
E = 3.5; % voltage of the wheatstone brige
amp = 100; % amplification used
a=10e-3; % bar radius
Ebar = 217e9; % Young's modulus of bar
C0=5100; % wave speed of bar
f_cutt = 300e3; % cutt-off frequency of the amplifier
%%%%%%%%%%%%%%%%%%%%%
Dsample=6e-3;
Asample = pi/4*(Dsample)^2;
Lsample = 4e-3;
% %%%%%%%%%%%%%%%%%%%%
mkdir([data_dir 'out'])
fout=[data_dir '/out/' vel '.out'];
d_bar = 2*a;
Abar = pi/4*(d_bar)^2;
Values(1)=Abar;
Values(2)=Asample;
Values(3)=Lsample;
% read the signal
signal= dlmread([ data_dir vel],',',23,0);
%%% read specific columns
% signal (:,1) = dlmread([ data_dir vel],',','D31..D20000');
% signal (:,2) = dlmread([ data_dir vel],',','E31..E20000');
% signal (:,3) = dlmread([ data_dir vel],',','K31..K20000');
% get the dispersion relation
dispersion_generate_curve (length(signal),signal(2,1)-signal(1,1),C0,a,'dispersion.mat')
% % % % % using optimization for finding the locations,
% % % % % % % % % assuming equibrium holds
options = optimset('TolFun',1e3,'TolX',1e3);
x0 = [0.5 0.5 ];
x = fminsearch(@SHPB_opt,x0,options);
distance_in = x(1);
distance_ref = -x(1);
distance_out = -x(2);
% % % % % % % % % % % % % % % % % % % % % % % % %
% % % % % % % % % % % % % % % % % % % % % % % % % %
% comment the optimizer and uncomment the below if manual processing is
% preferred
% distance_in = 0.63;
% distance_ref = -0.63;
% distance_out = -0.63;
% % % % % post process with the optimized distances or manual distance %
[Dispersed_signal,stress_in,stress_out,e_rate,strain] = ...
SHPB_process(signal,distance_in,distance_ref,distance_out,C0,a,amp,Ebar,Values,f_cutt);
% ===================================================================
% ================ Plotting begins ==================================
% ===================================================================
dis_in=Dispersed_signal(:,1);
dis_ref=Dispersed_signal(:,2);
dis_tra=Dispersed_signal(:,3);
dt=signal(2,1)-signal(1,1);
N=length(dis_in);
time=dt*(1:1:N);
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
figure(2)
p=length(dis_in)
plot((1:p)*dt*1e6,dis_in)
hold on
plot((1:p)*dt*1e6,-dis_ref)
hold on
plot((1:p)*dt*1e6,dis_tra)
figure(3)
clf()
plot(time*1e6,stress_out*Asample/1000,'LineWidth',2)
set(gca,'fontsize',14)
hold on
plot(time*1e6,stress_in*Asample/1000,'LineWidth',2)
set(gca,'fontsize',14)
% ylim([-20 200])
xlabel('Time (Microseconds)','FontSize', 14); ylabel('Force (kN)','FontSize', 14)
lgd = legend('Output force','Input force','location','northwest');
lgd.FontSize = 10.5;
% title(lgd,'Velocity 32.36 m/s','FontSize', 10.5)
rect = [0.1, 0.1, .1, .1];
% return
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
figure (4)
% % subplot(1,2,1)
% plot(-str,stress_jc,'--m','LineWidth',2)
% hold on
plot(-log(1-strain),(stress_out).*(1-strain)/1e6,'LineWidth',2) %%%%%%%%%% stress-strain by output signal%%%%%%%%%%
% hold on
% plot(m(:,2)/5,m(:,5),'m','LineWidth',2)
xlabel('True strain'); ylabel('True stress (MPa)')
xlim([0 inf]);
ylim([0 2000]);
figure(5)
plot(time*1e6,e_rate,'LineWidth',2)
xlabel('Time (Microseconds)'); ylabel('Strain rate (1/s)')
% fout=[data_dir vel '.out']
fp=fopen(fout,'w');
fprintf (fp,'true strain, true stress out MPa, true stress in MPa, strain rate 1/s\n');
fclose(fp)
stress_out=(stress_out).*(1-strain)/1e6;
stress_in=(stress_in).*(1-strain)/1e6;
% e_rate = -log(1-strain);
% strain
strain = -log(1-strain);
% strain
dlmwrite(fout,[strain' stress_out' stress_in' e_rate' dis_in dis_ref dis_tra],'-append','delimiter',',')
strain = strain' ;
stress_out = stress_out';
stress_in = stress_in';
e_rate = e_rate';
close(v)
% end