-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomputeAsmIntegrand.m
81 lines (67 loc) · 1.94 KB
/
computeAsmIntegrand.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
function [X, theta] = computeAsmIntegrand(func, ntheta, params)
% [X, theta] = computeAsmIntegrand(func, ntheta, asmParams)
%
%
% Example:
% p = generateAsmConfig('water', 'steel');
% p.f = linspace(100e3, 500e3, 500);
% ntheta = 500;
% [X, theta] = computeAsmIntegrand(...
% @integrandFluidSolidFluid_planepiston, ntheta, p);
%
% figure
% imagesc(p.f, theta, abs(X))
%% Pars default arguments
if nargin < 3
fprintf('Must have at least to input arguments.\n');
return;
end
if ~isa(func, 'function_handle')
fprintf('First input must be a function handle.\n');
return;
end
if ~params.debug
pdir = pwd();
cd(fileparts(mfilename('fullpath')));
gitStatus = git('status');
isunmodified = ~isempty(regexp(gitStatus, 'modified', 'ONCE'));
isnotup2date = ~isempty(regexp(gitStatus, 'up-to-date', 'ONCE'));
if isunmodified || isnotup2date
warning('The ASM repos is modified or not up-to-date!')
else
params.gitInfo = getGitInfo();
end
cd(pdir)
end
%% Samplings stuff
f = params.f;
thetamax = params.thetamax;
thetamin = 0;
theta = linspace(thetamin, thetamax, ntheta);
%% Unpack parameters
aRx = params.aRx;
aTx = params.aTx;
c_F = params.cf;
rho_F = params.rho_fluid;
rho_S = params.rho_solid;
cp = params.cp;
cs = params.cs;
thick = params.thickness;
d1 = params.distanceTx;
d3 = params.distanceRx;
al_dB = params.alphaLambda_dB;
fres = 0.5*params.cp/params.thickness; %#ok<*NASGU>
x0 = params.displaceRx;
refl = params.reflection;
%% Check sanity of parameters and give warnings or errors
% TODO: Implement sanity checks. Throw errors.
assert(al_dB >=0, 'asm:paramerror', 'The damping must be a positive number.');
%% Evaluate integrand over all angles for the point on the axis
X = zeros(length(f), ntheta);
for i = 1:length(f)
w = 2*pi*f(i);
k = w/c_F;
X(i, :) = func(theta, f(i), k, d1, d3, aTx, aRx, c_F,...
al_dB, refl, rho_F, rho_S, cp, cs, thick, x0);
end
end