Skip to content

Commit cf20fb8

Browse files
committedSep 4, 2019
another improvement in cdmv.m
1 parent d96f260 commit cf20fb8

File tree

2 files changed

+19
-34
lines changed

2 files changed

+19
-34
lines changed
 

‎nikkhoo/README.md

+5-7
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@ The proposed scripts are literal transcriptions of the Nikkhoo's equations from
2828
|DEPTH | Depth of the source from calculation points, same unit as X and Y. Note that you might add the elevation at each calculation points to approximate the topographic effects.|
2929
|OMEGAX OMEGAY OMEGAZ| Clockwise rotation angles around X, Y and Z axes, respectively, that specify the orientation of the CDM in space, in degrees.|
3030
|NU | Poisson's ratio, optional and dimensionless (default is 0.25 for an isotropic medium).|
31-
32-
|Output arguments|Description|
33-
|-------------:|:----------|
31+
| | |
32+
|**Output arguments**|**Description**|
3433
|uE uN uV| Calculated displacement vector components in EFCS. Will have the same unit as X, Y and DEPTH.|
3534

3635
## CDM code
@@ -43,9 +42,8 @@ The proposed scripts are literal transcriptions of the Nikkhoo's equations from
4342
|-------------:|:----------|
4443
|AX AY AZ| Semi-axes of the CDM along the X, Y and Z axes, respectively, before applying the rotations. AX, AY and AZ have the same unit as X and Y.|
4544
|OPENING | The opening (tensile component of the Burgers vector) of the rectangular dislocation that form the CDM. Same unit as AX, AY and AZ.|
46-
47-
|Output arguments|Description|
48-
|-------------:|:----------|
45+
| | |
46+
|**Output arguments**|**Description**|
4947
|dV| Potency of the CDM. DV has the unit of volume, i.e. the unit of displacements, OPENING and CDM semi-axes to the power of 3.|
5048

5149

@@ -124,7 +122,7 @@ Since the original scripts where vectorized for observation points only, the gai
124122
|code| CDM @Matlab| CDM @Octave | pCDM @Matlab| pCDM @Octave |
125123
|----:|--------:|-------:|----:|----:|
126124
|original .m | 3 mn|- | 8.0 s| 5 mn |
127-
|vectorized .m |5.5 s| 16 s| 0.9 s| 1.7 s|
125+
|vectorized .m |4.6 s| 16 s| 0.9 s| 1.7 s|
128126
|compiled .mex (.c)|2.4 s| 2.4 s| 0.4 s| 0.4 s|
129127

130128
## Rerefences

‎nikkhoo/cdmv.m

+14-27
Original file line numberDiff line numberDiff line change
@@ -250,20 +250,6 @@
250250
end
251251

252252

253-
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
254-
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
255-
function [X1,X2,X3]=CoordTrans(x1,x2,x3,A1,A2,A3)
256-
% CoordTrans transforms the coordinates of the vectors, from
257-
% x1x2x3 coordinate system to X1X2X3 coordinate system. The transformation
258-
% whose columns A1, A2 and A3 are the unit base vectors of the x1x2x3. The
259-
% coordinates of e1,e2 and e3 in A must be given in X1X2X3. The transpose
260-
% of A (i.e., A') will transform the coordinates from X1X2X3 into x1x2x3.
261-
262-
X1 = A1(:,1).*x1 + A1(:,2).*x2 + A1(:,3).*x3;
263-
X2 = A2(:,1).*x1 + A2(:,2).*x2 + A2(:,3).*x3;
264-
X3 = A3(:,1).*x1 + A3(:,2).*x2 + A3(:,3).*x3;
265-
end
266-
267253
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
268254
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
269255
function [ue,un,uv]=AngSetupFSC(X,Y,bX,bY,bZ,PA,PB,nu2)
@@ -272,22 +258,23 @@
272258

273259
SideVec = PB-PA;
274260
beta = acos(-SideVec(:,3)./sqrt(sum(SideVec.^2,2)));
261+
Vnorm = sqrt(sum(SideVec(:,1:2).^2,2));
275262

276-
ey1 = [SideVec(:,1:2),zeros(size(X))];
277-
ey1 = ey1./repmat(sqrt(sum(ey1.^2,2)),1,3);
278-
ey3 = repmat([0 0 -1],length(X),1);
279-
%ey2 = cross(ey3,ey1,2);
280-
ey2 = [ey1(:,2),-ey1(:,1),zeros(size(X))];
263+
A1 = SideVec(:,1)./Vnorm;
264+
A2 = SideVec(:,2)./Vnorm;
281265

282266
% Transform coordinates from EFCS to the first ADCS
283-
[y1A,y2A,~] = CoordTrans(X-PA(:,1),Y-PA(:,2),-PA(:,3),ey1,ey2,ey3);
267+
y1A = A1.*(X - PA(:,1)) + A2.*(Y - PA(:,2));
268+
y2A = A2.*(X - PA(:,1)) - A1.*(Y - PA(:,2));
269+
284270
% Transform coordinates from EFCS to the second ADCS
285-
[y1AB,y2AB,~] = CoordTrans(SideVec(:,1),SideVec(:,2),SideVec(:,3),ey1,ey2,ey3);
286-
y1B = y1A-y1AB;
287-
y2B = y2A-y2AB;
271+
y1B = y1A - (A1.*SideVec(:,1) + A2.*SideVec(:,2));
272+
y2B = y2A - (A2.*SideVec(:,1) - A1.*SideVec(:,2));
288273

289274
% Transform slip vector components from EFCS to ADCS
290-
[b1,b2,b3] = CoordTrans(bX,bY,bZ,ey1,ey2,ey3);
275+
b1 = A1.*bX + A2.*bY;
276+
b2 = A2.*bX - A1.*bY;
277+
b3 = -bZ;
291278

292279
[v1A,v2A,v3A] = AngDisDispSurf(y1A,y2A,beta,b1,b2,b3,nu2,-PA(:,3));
293280
[v1B,v2B,v3B] = AngDisDispSurf(y1B,y2B,beta,b1,b2,b3,nu2,-PB(:,3));
@@ -305,9 +292,9 @@
305292
v3 = v3B - v3A;
306293

307294
% Transform total displacements from ADCS to EFCS
308-
ue = ey1(:,1).*v1 + ey2(:,1).*v2;
309-
un = ey1(:,2).*v1 + ey2(:,2).*v2;
310-
uv = ey3(:,3).*v3;
295+
ue = A1.*v1 + A2.*v2;
296+
un = A2.*v1 - A1.*v2;
297+
uv = -v3;
311298

312299
k = abs(beta)<eps | abs(pi-beta)<eps;
313300
ue(k) = 0;

0 commit comments

Comments
 (0)
Please sign in to comment.