diff --git a/input/FRS_111_generator.m b/input/FRS_111_generator.m index 4b7deb1e..963a9733 100644 --- a/input/FRS_111_generator.m +++ b/input/FRS_111_generator.m @@ -3,111 +3,107 @@ global Bscrew Bedge Beclimb Bline bmag = 2.74E-4; %microns -mumag = 160e3; % MPa -l = 0.5/bmag; -b = 1/2*[1 1 1]; +mumag = 160e3; % MPa +l = 0.5 / bmag; +b = 1/2 * [1 1 1]; +side1 = [1 1 1] / sqrt(3); -side1 = [1 1 1]/sqrt(3); - - -n = [-1 0 1] %cross(side2,b); +n = [-1 0 1]%cross(side2,b); %start from center of grid %P1 = [0.52 0.52 1.7]/bmag; %exiting top %P1 = [0.52 0.1 0.52]/bmag; %lateral -dx=5; %microns -dy=2; %microns -dz=2; %microns -ns= 10 %number of sources - -P1 = [dx 0.5*dy, 0.8*dz]/bmag; -P2m = P1 + l*side1*0.5; -P2 = P1 + l*side1; - - -P3 = [0.05*dx 0.5*dy, 0.2*dz]/bmag; -P3m = P3 + l*side1*0.5; -P4 = P3 + l*side1; - - -rn = [ - P1, 7; - P2m, 0; - P2, 7; - P3, 7; - P3m, 0; - P4, 7; - ]; - -links = [ 1 2 b n; - 2 3 b n; - 4 5 b n; - 5 6 b n; - ]; - -MU = 1; -NU = 0.305; -maxconnections=4; -lmax = 1000; -lmin = 100; +dx = 5; %microns +dy = 2; %microns +dz = 2; %microns +ns = 10%number of sources + +P1 = [dx 0.5 * dy, 0.8 * dz] / bmag; +P2m = P1 + l * side1 * 0.5; +P2 = P1 + l * side1; + +P3 = [0.05 * dx 0.5 * dy, 0.2 * dz] / bmag; +P3m = P3 + l * side1 * 0.5; +P4 = P3 + l * side1; + +rn = [ + P1, 7; + P2m, 0; + P2, 7; + P3, 7; + P3m, 0; + P4, 7; + ]; + +links = [1 2 b n; + 2 3 b n; + 4 5 b n; + 5 6 b n; + ]; + +MU = 1; +NU = 0.305; +maxconnections = 4; +lmax = 1000; +lmin = 100; coplanar_tol = 10; -areamin=lmin*lmin*sin(60/180*pi)*0.5; -areamax=20*areamin; -a=lmin/sqrt(3)*0.5; -Ec = MU/(4*pi)*log(a/0.1); -dt0=1e7; -mobility='mobbcc0'; +areamin = lmin * lmin * sin(60/180 * pi) * 0.5; +areamax = 20 * areamin; +a = lmin / sqrt(3) * 0.5; +Ec = MU / (4 * pi) * log(a / 0.1); +dt0 = 1e7; +mobility = 'mobbcc0'; intSimTime = 0; sinTime = 0; -dtplot=5e6; -doplot=1;% frame recording: 1 == on, 0 == off +dtplot = 5e6; +doplot = 1; % frame recording: 1 == on, 0 == off totalSimTime = 0.3e12; curstep = 0; simTime = 0; -Bscrew=1e0; -Bedge=1e0; -Beclimb=1e10; -Bline=1.0e-4*min(Bscrew,Bedge); - -integrator='int_trapezoid'; -rann = 0.5*a; -rntol = 0.5*rann; -doremesh=1; %flat set to 0 or 1 that turns the remesh functions off or on -docollision=1; %flat set to 0 or 1 that turns collision detection off or on -doseparation=1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on -dovirtmesh=1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on -plotfreq=100; -plim=7000; -viewangle=[-35,15]; -printfreq=1; -printnode=2; -rmax=100; %maximum distance a node may travel in one cycle +Bscrew = 1e0; +Bedge = 1e0; +Beclimb = 1e10; +Bline = 1.0e-4 * min(Bscrew, Bedge); + +integrator = 'int_trapezoid'; +rann = 0.5 * a; +rntol = 0.5 * rann; +doremesh = 1; %flat set to 0 or 1 that turns the remesh functions off or on +docollision = 1; %flat set to 0 or 1 that turns collision detection off or on +doseparation = 1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on +dovirtmesh = 1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on +plotFreq = 100; +plim = 7000; +viewangle = [-35, 15]; +printfreq = 1; +printnode = 2; +rmax = 100; %maximum distance a node may travel in one cycle %FEM CANTILEVER PARAMETERS % dx=12; %microns -% dy=2; %microns +% dy=2; %microns % dz=2; %microns %tungsten "a" is 0.000274 -dx = dx/bmag; -dy = dy/bmag; -dz = dz/bmag; - -mx=30; % number of elements along beam length -loading=1; -vertices = [0,0,0;... - dx,0,0;... - 0,dy,0;... - dx,dy,0;... - 0,0,dz;... - dx,0,dz;... - 0,dy,dz;... - dx,dy,dz]; +dx = dx / bmag; +dy = dy / bmag; +dz = dz / bmag; + +mx = 30; % number of elements along beam length +loading = 1; +vertices = [0, 0, 0; ... + dx, 0, 0; ... + 0, dy, 0; ... + dx, dy, 0; ... + 0, 0, dz; ... + dx, 0, dz; ... + 0, dy, dz; ... + dx, dy, dz]; %plotnodes(rn,links,plim,vertices); hold on; -plot3(rn(:,1), rn(:,2), rn(:,3),'ko'); %nodes +plot3(rn(:, 1), rn(:, 2), rn(:, 3), 'ko'); %nodes diff --git a/input/gen_110m111.m b/input/gen_110m111.m index 7157d624..a51ee65e 100644 --- a/input/gen_110m111.m +++ b/input/gen_110m111.m @@ -23,43 +23,43 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clear all %% SOURCE GENERATION PARAMETERS -amag=3.18e-4; -mumag = 145E3; % MPa only used for plotting +amag = 3.18e-4; +mumag = 145E3; % MPa only used for plotting CRYSTAL_STRUCTURE = 'bcc'; NUM_SOURCES = 1; -DIST_SOURCE = 0.26/amag; +DIST_SOURCE = 0.26 / amag; %% FEM PARAMETERS %Cantilever -dx=15/amag; %10micron -dy=5/amag; %2micron -dz=5/amag; %2micron - -mx=40; % number of elements along beam length -loading=1; -vertices = [0,0,0;... - dx,0,0;... - 0,dy,0;... - dx,dy,0;... - 0,0,dz;... - dx,0,dz;... - 0,dy,dz;... - dx,dy,dz]; +dx = 15 / amag; %10micron +dy = 5 / amag; %2micron +dz = 5 / amag; %2micron + +mx = 40; % number of elements along beam length +loading = 1; +vertices = [0, 0, 0; ... + dx, 0, 0; ... + 0, dy, 0; ... + dx, dy, 0; ... + 0, 0, dz; ... + dx, 0, dz; ... + 0, dy, dz; ... + dx, dy, dz]; %% MATERIAL CONSTANTS %MU = 160E9; %160GPa MU = 1; -NU = 0.28; +NU = 0.28; %% DDLab PARAMETERS % c=1/amag; % x=0.25/(amag*sqrt(6)); % y=0.25/(amag*sqrt(3)); -% +% % rn=[ 3.7*c 2.7*c+2*x-y 0.25*c 0; % 3.7*c+x 2.7*c-y 0.25*c+x 0; % 3.7*c+2*x 2.7*c-2*x-y 0.25*c+2*x 0; @@ -68,21 +68,21 @@ % 3.7*c+x+2*y 2.7*c+y 0.25*c+x+2*y 0; % 3.7*c+2*y 2.7*c+2*x+y 0.25*c+2*y 0; % 3.7*c+y 2.7*c+2*x 0.25*c+y 0]; -% +% % b1=[-1 -1 -1]/sqrt(3); % n1=[-1 0 1]/sqrt(2); % n2=[1 0 -1]/sqrt(2); -% +% % links=[1 2 b1 n1; % 2 3 b1 n1; -% 3 4 b1 n1; +% 3 4 b1 n1; % 4 5 b1 n1; % 5 6 b1 n1; % 6 7 b1 n1; % 7 8 b1 n1; % 8 1 b1 n1]; - - [rn,links] = input_110m111(NUM_SOURCES,DIST_SOURCE,dx,dy,dz); + +[rn, links] = input_110m111(NUM_SOURCES, DIST_SOURCE, dx, dy, dz); % [rn]=[dx-0.5*dx,dy-0.5*dy,dz-0.5*dz,7; % dx-0.5*dx,dy-0.5*dy,dz-0.55*dz,7; % dx-0.49*dx,dy-0.5*dy,dz-0.55*dz,7]; @@ -95,67 +95,67 @@ % links_mirror = links; % links_mirror(:,1) = links(:,2) + max(max(links(:,1:2))); % links_mirror(:,2) = links(:,1) + max(max(links(:,1:2))); -% +% % rn = vertcat(rn,rn_mirror); % links = vertcat(links,links_mirror); %% %Edge and screw glide and climb mobility parameters -mobility='Hmobbcc10rotation'; +mobility = 'Hmobbcc10rotation'; global Bscrew Bedge Beclimb Bline %Bedge=1e-4; %Pa s %Bscrew=1e-5; %Pa s %Beclimb=1e5; %Pa s - really big %Bline=1e-4*min(Bscrew,Bedge); -Bedge=1; -Bscrew=2; -Beclimb=1e10; -Bline=1e-4*min(Bscrew,Bedge); +Bedge = 1; +Bscrew = 2; +Beclimb = 1e10; +Bline = 1e-4 * min(Bscrew, Bedge); %Meshing -maxconnections=4; -lmax =0.5/amag; -lmin = 0.1/amag; -areamin=lmin*lmin*sin(60/180*pi)*0.5; -areamax=20*areamin; -doremesh=1; %flat set to 0 or 1 that turns the remesh functions off or on -docollision=1; %flat set to 0 or 1 that turns collision detection off or on -doseparation=1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on -dovirtmesh=1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on +maxconnections = 4; +lmax = 0.5 / amag; +lmin = 0.1 / amag; +areamin = lmin * lmin * sin(60/180 * pi) * 0.5; +areamax = 20 * areamin; +doremesh = 1; %flat set to 0 or 1 that turns the remesh functions off or on +docollision = 1; %flat set to 0 or 1 that turns collision detection off or on +doseparation = 1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on +dovirtmesh = 1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on %Simulation time -dt0=1E10; +dt0 = 1E10; intSimTime = 0; sinTime = 0; %dtplot=2E-9; %2ns -dtplot=5E4; -doplot=1; % frame recording: 1 == on, 0 == off -totalSimTime = (2/amag)/(0.0001*1E3*dx*(1E-4/160E9)); +dtplot = 5E4; +doplot = 1; % frame recording: 1 == on, 0 == off +totalSimTime = (2 / amag) / (0.0001 * 1E3 * dx * (1E-4/160E9)); curstep = 0; simTime = 0; %Integrator -integrator='int_trapezoid_bb'; +integrator = 'int_trapezoid_bb'; %integrator='int_trapezoid_stoc'; %in development -a=lmin/sqrt(3)*0.5; -Ec = MU/(4*pi)*log(a/0.1); -rann = 0.5*a; -rntol = 0.5*rann; % need to do convergence studies on all these parameters +a = lmin / sqrt(3) * 0.5; +Ec = MU / (4 * pi) * log(a / 0.1); +rann = 0.5 * a; +rntol = 0.5 * rann; % need to do convergence studies on all these parameters rmax = lmax; %Plotting -plotfreq=10E7; -plim=12/amag; %12microns -viewangle=[-35,15]; -printfreq=500; -printnode=2; +plotFreq = 10E7; +plim = 12 / amag; %12microns +viewangle = [-35, 15]; +printfreq = 500; +printnode = 2; %GPU Setup use_gpu = 0; -n_threads=256; +n_threads = 256; % tractions a_trac = 1; -save('./mat_files/test') \ No newline at end of file +save('./mat_files/test') diff --git a/input/genpris_101_111.m b/input/genpris_101_111.m index ca3dc062..13dba287 100644 --- a/input/genpris_101_111.m +++ b/input/genpris_101_111.m @@ -23,43 +23,43 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clear all %% SOURCE GENERATION PARAMETERS -amag=3.18e-4; -mumag = 145E3; % MPa only used for plotting +amag = 3.18e-4; +mumag = 145E3; % MPa only used for plotting CRYSTAL_STRUCTURE = 'bcc'; NUM_SOURCES = 1; -DIST_SOURCE = 0.26/amag; +DIST_SOURCE = 0.26 / amag; %% FEM PARAMETERS %Cantilever -dx=15/amag; %10micron -dy=5/amag; %2micron -dz=5/amag; %2micron - -mx=40; % number of elements along beam length -loading=1; -vertices = [0,0,0;... - dx,0,0;... - 0,dy,0;... - dx,dy,0;... - 0,0,dz;... - dx,0,dz;... - 0,dy,dz;... - dx,dy,dz]; +dx = 15 / amag; %10micron +dy = 5 / amag; %2micron +dz = 5 / amag; %2micron + +mx = 40; % number of elements along beam length +loading = 1; +vertices = [0, 0, 0; ... + dx, 0, 0; ... + 0, dy, 0; ... + dx, dy, 0; ... + 0, 0, dz; ... + dx, 0, dz; ... + 0, dy, dz; ... + dx, dy, dz]; %% MATERIAL CONSTANTS %MU = 160E9; %160GPa MU = 1; -NU = 0.28; +NU = 0.28; %% DDLab PARAMETERS % c=1/amag; % x=0.25/(amag*sqrt(6)); % y=0.25/(amag*sqrt(3)); -% +% % rn=[ 3.7*c 2.7*c+2*x-y 0.25*c 0; % 3.7*c+x 2.7*c-y 0.25*c+x 0; % 3.7*c+2*x 2.7*c-2*x-y 0.25*c+2*x 0; @@ -68,21 +68,21 @@ % 3.7*c+x+2*y 2.7*c+y 0.25*c+x+2*y 0; % 3.7*c+2*y 2.7*c+2*x+y 0.25*c+2*y 0; % 3.7*c+y 2.7*c+2*x 0.25*c+y 0]; -% +% % b1=[-1 -1 -1]/sqrt(3); % n1=[-1 0 1]/sqrt(2); % n2=[1 0 -1]/sqrt(2); -% +% % links=[1 2 b1 n1; % 2 3 b1 n1; -% 3 4 b1 n1; +% 3 4 b1 n1; % 4 5 b1 n1; % 5 6 b1 n1; % 6 7 b1 n1; % 7 8 b1 n1; % 8 1 b1 n1]; - - [rn,links] = inputpris_101_111(NUM_SOURCES,DIST_SOURCE,dx,dy,dz); + +[rn, links] = inputpris_101_111(NUM_SOURCES, DIST_SOURCE, dx, dy, dz); % [rn]=[dx-0.5*dx,dy-0.5*dy,dz-0.5*dz,7; % dx-0.5*dx,dy-0.5*dy,dz-0.55*dz,7; % dx-0.49*dx,dy-0.5*dy,dz-0.55*dz,7]; @@ -95,33 +95,33 @@ % links_mirror = links; % links_mirror(:,1) = links(:,2) + max(max(links(:,1:2))); % links_mirror(:,2) = links(:,1) + max(max(links(:,1:2))); -% +% % rn = vertcat(rn,rn_mirror); % links = vertcat(links,links_mirror); %% %Edge and screw glide and climb mobility parameters -mobility='Hmobbcc10rotation';%'mobbcc1'; +mobility = 'Hmobbcc10rotation'; %'mobbcc1'; global Bscrew Bedge Beclimb Bline %Bedge=1e-4; %Pa s %Bscrew=1e-5; %Pa s %Beclimb=1e5; %Pa s - really big %Bline=1e-4*min(Bscrew,Bedge); -Bedge=1; -Bscrew=2; -Beclimb=1e10; -Bline=1e-4*min(Bscrew,Bedge); +Bedge = 1; +Bscrew = 2; +Beclimb = 1e10; +Bline = 1e-4 * min(Bscrew, Bedge); %Meshing -maxconnections=4; -lmax =0.5/amag; -lmin = 0.1/amag; -areamin=lmin*lmin*sin(60/180*pi)*0.5; -areamax=20*areamin; -doremesh=1; %flat set to 0 or 1 that turns the remesh functions off or on -docollision=1; %flat set to 0 or 1 that turns collision detection off or on -doseparation=1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on -dovirtmesh=1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on +maxconnections = 4; +lmax = 0.5 / amag; +lmin = 0.1 / amag; +areamin = lmin * lmin * sin(60/180 * pi) * 0.5; +areamax = 20 * areamin; +doremesh = 1; %flat set to 0 or 1 that turns the remesh functions off or on +docollision = 1; %flat set to 0 or 1 that turns collision detection off or on +doseparation = 1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on +dovirtmesh = 1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on %Simulation time dt0 = 1E6; @@ -130,39 +130,39 @@ intSimTime = 0; sinTime = 0; %dtplot=2E-9; %2ns -dtplot=5E4; -doplot=1; % frame recording: 1 == on, 0 == off +dtplot = 5E4; +doplot = 1; % frame recording: 1 == on, 0 == off % totalSimTime = (2/amag)/(100*1E3*dx*(1E-4/160E9)); -totalSimTime = (2/amag)/(0.001*1E3*dx*(1E-4/160E9)); +totalSimTime = (2 / amag) / (0.001 * 1E3 * dx * (1E-4/160E9)); curstep = 0; simTime = 0; %Integrator -integrator='int_trapezoid_bb'; +integrator = 'int_trapezoid_bb'; %integrator='int_trapezoid_stoc'; %in development -a=lmin/sqrt(3)*0.5; -Ec = MU/(4*pi)*log(a/0.1); -rann = 0.5*a; -rntol = 0.5*rann; % need to do convergence studies on all these parameters +a = lmin / sqrt(3) * 0.5; +Ec = MU / (4 * pi) * log(a / 0.1); +rann = 0.5 * a; +rntol = 0.5 * rann; % need to do convergence studies on all these parameters rmax = lmax; %Plotting -plotfreq=10E7; -plim=12/amag; %12microns -viewangle=[-35,15]; -printfreq=500; -printnode=2; +plotFreq = 10E7; +plim = 12 / amag; %12microns +viewangle = [-35, 15]; +printfreq = 500; +printnode = 2; %GPU Setup use_gpu = 0; -n_threads=256; +n_threads = 256; a_trac = 1; simple = 1; % Haiyang's screw dislocation correction global do_cross_slip do_reset last_step L_cross_crit -do_cross_slip=1; +do_cross_slip = 1; do_reset = 1; last_step = 0; -L_cross_crit = 4*lmax; -save('./mat_files/20200117') \ No newline at end of file +L_cross_crit = 4 * lmax; +save('./mat_files/20200117') diff --git a/input/i_prismatic_bcc.m b/input/i_prismatic_bcc.m index 5a36224b..c74a1973 100644 --- a/input/i_prismatic_bcc.m +++ b/input/i_prismatic_bcc.m @@ -59,10 +59,10 @@ % % Plotting. % -% plotfreq := plot frequency. +% plotFreq := plot frequency. % plim := plot limit. % printfreq := print frequency. -% printnode := +% printnode := % viewangle := view angle for plot in deg. % % Meshing. @@ -92,15 +92,15 @@ %% Source generation. % Values are for tungsten. -a_m = 2.856e-4; +a_m = 2.856e-4; mu_m = 82E3; -b_m = sqrt(3)/2; +b_m = sqrt(3) / 2; crys_struct = 'bcc'; n_source = 10; -d_source = 0.2/a_m; -l_source = 80*b_m; +d_source = 0.2 / a_m; +l_source = 80 * b_m; %% Material constants. global MU NU @@ -113,25 +113,25 @@ % Rectangular prism cantilever. % Dimensions. -dx = 12/a_m; -dy = 3/a_m; -dz = 3/a_m; - -vertices = [0 , 0 , 0 ;... - dx, 0 , 0 ;... - 0 , dy, 0 ;... - dx, dy, 0 ;... - 0 , 0 , dz ;... - dx, 0 , dz ;... - 0 , dy, dz ;... +dx = 12 / a_m; +dy = 3 / a_m; +dz = 3 / a_m; + +vertices = [0, 0, 0; ... + dx, 0, 0; ... + 0, dy, 0; ... + dx, dy, 0; ... + 0, 0, dz; ... + dx, 0, dz; ... + 0, dy, dz; ... dx, dy, dz]; - -fem_n = [-1 0 0;... % min(x), yz-plane, face 1 - 1 0 0;... % max(x), yz-plane, face 2 - 0 -1 0;... % min(y), xz-plane, face 4 - 0 1 0;... % max(y), xz-plane, face 3 - 0 0 -1;... % min(z), xy-plane, face 5 - 0 0 1]; % max(z), xy-plane, face 6 + +fem_n = [-1 0 0; ...% min(x), yz-plane, face 1 + 1 0 0; ...% max(x), yz-plane, face 2 + 0 -1 0; ...% min(y), xz-plane, face 4 + 0 1 0; ...% max(y), xz-plane, face 3 + 0 0 -1; ...% min(z), xy-plane, face 5 + 0 0 1]; % max(z), xy-plane, face 6 % Loading type. loading = 1; @@ -145,57 +145,57 @@ global Ubarglobal % Flags. -flag_NRF = 0; +flag_NRF = 0; flag_Junction = 0; -unloadflag = 0; -unloadcount = 0; -Ubarglobal = 0; +unloadflag = 0; +unloadcount = 0; +Ubarglobal = 0; % Mobility law. -mobility='Hmobbcc1'; +mobility = 'Hmobbcc1'; % Values are for tungsten. -Bedge = 5E-4; -Bscrew = 100E-4; +Bedge = 5E-4; +Bscrew = 100E-4; Beclimb = 1e5; -Bline = 1e-4*min(Bscrew,Bedge); +Bline = 1e-4 * min(Bscrew, Bedge); % Plotting parameters. -plotfreq = 1000; -plim = 12/a_m; -printfreq = 1000; +plotFreq = 1000; +plim = 12 / a_m; +printfreq = 1000; printnode = 2; -viewangle = [30,60]; +viewangle = [30, 60]; % Dislocation node and segment generator. slips = [3]; [rn, links] = prismatic_bcc_generator(slips, dx, dy, dz, vertices, fem_n); % Meshing parameters. -maxconnections = 4; -lmax = 0.1/a_m; -lmin = 0.02/a_m; -areamin = lmin*lmin*sin(60/180*pi)*0.5; -areamax = 20*areamin; +maxconnections = 4; +lmax = 0.1 / a_m; +lmin = 0.02 / a_m; +areamin = lmin * lmin * sin(60/180 * pi) * 0.5; +areamax = 20 * areamin; % DDLab flags. -doplot = 1; -dosave = 0; +doplot = 1; +dosave = 0; doremesh = 1; -docollision = 1; +docollision = 1; doseparation = 1; -dovirtmesh = 1; +dovirtmesh = 1; % Runtime parameters. savefreq = 10; % Temporal variables. dt0 = 1E8; -dt = 1E8; +dt = 1E8; dtplot = 0; intSimTime = 0; -sinTime = 0; +sinTime = 0; totalSimTime = 1E15; curstep = 0; @@ -203,11 +203,11 @@ % Integrator. All these require convergence studies. integrator = 'int_trapezoid'; -a = 40*b_m; -Ec = MU/(4*pi)*log(a/0.1); -rann = 0.5*a; -rntol = 0.5*rann; -rmax = lmax; +a = 40 * b_m; +Ec = MU / (4 * pi) * log(a / 0.1); +rann = 0.5 * a; +rntol = 0.5 * rann; +rmax = lmax; maxSeg = lmax; -%plotnodes(rn,links,0,vertices) \ No newline at end of file +%plotnodes(rn,links,0,vertices) diff --git a/input/input101.m b/input/input101.m index 5d418a8f..6d79b831 100644 --- a/input/input101.m +++ b/input/input101.m @@ -23,31 +23,31 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clear all %% SOURCE GENERATION PARAMETERS -amag=3.18e-4; +amag = 3.18e-4; mumag = 160E3; % MPa only used for plotting CRYSTAL_STRUCTURE = 'bcc'; NUM_SOURCES = 10; -DIST_SOURCE = 0.5/amag; +DIST_SOURCE = 0.5 / amag; %% FEM PARAMETERS %Cantilever -dx=30/amag; %10micron -dy=5/amag; %2micron -dz=5/amag; %2micron - -mx=50; % number of elements along beam length -loading=1; -vertices = [0,0,0;... - dx,0,0;... - 0,dy,0;... - dx,dy,0;... - 0,0,dz;... - dx,0,dz;... - 0,dy,dz;... - dx,dy,dz]; +dx = 30 / amag; %10micron +dy = 5 / amag; %2micron +dz = 5 / amag; %2micron + +mx = 50; % number of elements along beam length +loading = 1; +vertices = [0, 0, 0; ... + dx, 0, 0; ... + 0, dy, 0; ... + dx, dy, 0; ... + 0, 0, dz; ... + dx, 0, dz; ... + 0, dy, dz; ... + dx, dy, dz]; %% MATERIAL CONSTANTS @@ -58,65 +58,65 @@ %% DDLab PARAMETERS %Dislocation nodes and segments generator -[rn,links] = checkGenerator101(NUM_SOURCES,DIST_SOURCE,CRYSTAL_STRUCTURE,dx,dy,dz); +[rn, links] = checkGenerator101(NUM_SOURCES, DIST_SOURCE, CRYSTAL_STRUCTURE, dx, dy, dz); %create mirror of prismatic loops (outside boundary) -rn_mirror = [rn(:,1)+dx , rn(:,2) , rn(:,3)+dx , zeros(length(rn(:,1)),1)+67]; +rn_mirror = [rn(:, 1) + dx, rn(:, 2), rn(:, 3) + dx, zeros(length(rn(:, 1)), 1) + 67]; links_mirror = links; -links_mirror(:,1) = links(:,2) + max(max(links(:,1:2))); -links_mirror(:,2) = links(:,1) + max(max(links(:,1:2))); +links_mirror(:, 1) = links(:, 2) + max(max(links(:, 1:2))); +links_mirror(:, 2) = links(:, 1) + max(max(links(:, 1:2))); -rn = vertcat(rn,rn_mirror); -links = vertcat(links,links_mirror); +rn = vertcat(rn, rn_mirror); +links = vertcat(links, links_mirror); %% %Edge and screw glide and climb mobility parameters -mobility='mobbcc1'; +mobility = 'mobbcc1'; global Bscrew Bedge Beclimb Bline %Bedge=1e-4; %Pa s %Bscrew=1e-5; %Pa s %Beclimb=1e5; %Pa s - really big %Bline=1e-4*min(Bscrew,Bedge); -Bedge=1; -Bscrew=10; -Beclimb=1e10; -Bline=1e-4*min(Bscrew,Bedge); +Bedge = 1; +Bscrew = 10; +Beclimb = 1e10; +Bline = 1e-4 * min(Bscrew, Bedge); %Meshing -maxconnections=4; -lmax =0.25/amag; -lmin = 0.1/amag; -areamin=lmin*lmin*sin(60/180*pi)*0.5; -areamax=20*areamin; -doremesh=1; %flat set to 0 or 1 that turns the remesh functions off or on -docollision=1; %flat set to 0 or 1 that turns collision detection off or on -doseparation=1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on -dovirtmesh=1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on +maxconnections = 4; +lmax = 0.25 / amag; +lmin = 0.1 / amag; +areamin = lmin * lmin * sin(60/180 * pi) * 0.5; +areamax = 20 * areamin; +doremesh = 1; %flat set to 0 or 1 that turns the remesh functions off or on +docollision = 1; %flat set to 0 or 1 that turns collision detection off or on +doseparation = 1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on +dovirtmesh = 1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on %Simulation time -dt0=1E5; +dt0 = 1E5; intSimTime = 0; sinTime = 0; %dtplot=2E-9; %2ns -dtplot=1E6; -doplot=1; % frame recording: 1 == on, 0 == off +dtplot = 1E6; +doplot = 1; % frame recording: 1 == on, 0 == off totalSimTime = 1E12; curstep = 0; simTime = 0; %Integrator -integrator='int_trapezoid'; +integrator = 'int_trapezoid'; %integrator='int_trapezoid_stoc'; %in development -a=lmin/sqrt(3)*0.5; -Ec = MU/(4*pi)*log(a/0.1); -rann = 0.5*a; -rntol = 0.5*rann; % need to do convergence studies on all these parameters +a = lmin / sqrt(3) * 0.5; +Ec = MU / (4 * pi) * log(a / 0.1); +rann = 0.5 * a; +rntol = 0.5 * rann; % need to do convergence studies on all these parameters rmax = lmax; %Plotting -plotfreq=10; -plim=12/amag; %12microns -viewangle=[-35,15]; -printfreq=1; -printnode=2; +plotFreq = 10; +plim = 12 / amag; %12microns +viewangle = [-35, 15]; +printfreq = 1; +printnode = 2; diff --git a/input/input101checkGPU.m b/input/input101checkGPU.m index c269d747..ee5d0323 100644 --- a/input/input101checkGPU.m +++ b/input/input101checkGPU.m @@ -23,41 +23,41 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clear all %% SOURCE GENERATION PARAMETERS -amag=3.18e-4; -mumag = 160E3; % MPa only used for plotting +amag = 3.18e-4; +mumag = 160E3; % MPa only used for plotting CRYSTAL_STRUCTURE = 'bcc'; NUM_SOURCES = 4; -DIST_SOURCE = 0.5/amag; +DIST_SOURCE = 0.5 / amag; %% FEM PARAMETERS %Cantilever -dx=30/amag; %10micron -dy=5/amag; %2micron -dz=5/amag; %2micron - -mx=20; % number of elements along beam length -loading=1; -vertices = [0,0,0;... - dx,0,0;... - 0,dy,0;... - dx,dy,0;... - 0,0,dz;... - dx,0,dz;... - 0,dy,dz;... - dx,dy,dz]; +dx = 30 / amag; %10micron +dy = 5 / amag; %2micron +dz = 5 / amag; %2micron + +mx = 20; % number of elements along beam length +loading = 1; +vertices = [0, 0, 0; ... + dx, 0, 0; ... + 0, dy, 0; ... + dx, dy, 0; ... + 0, 0, dz; ... + dx, 0, dz; ... + 0, dy, dz; ... + dx, dy, dz]; %% MATERIAL CONSTANTS %MU = 160E9; %160GPa MU = 1; -NU = 0.305; +NU = 0.305; %% DDLab PARAMETERS %Dislocation nodes and segments generator -[rn,links] = checkGenerator101(NUM_SOURCES,DIST_SOURCE,CRYSTAL_STRUCTURE,dx,dy,dz); +[rn, links] = checkGenerator101(NUM_SOURCES, DIST_SOURCE, CRYSTAL_STRUCTURE, dx, dy, dz); %load('rnlinks_checkGPU'); %create mirror of prismatic loops (outside boundary) @@ -65,59 +65,58 @@ % links_mirror = links; % links_mirror(:,1) = links(:,2) + max(max(links(:,1:2))); % links_mirror(:,2) = links(:,1) + max(max(links(:,1:2))); -% +% % rn = vertcat(rn,rn_mirror); % links = vertcat(links,links_mirror); %% %Edge and screw glide and climb mobility parameters -mobility='mobbcc1'; +mobility = 'mobbcc1'; global Bscrew Bedge Beclimb Bline %Bedge=1e-4; %Pa s %Bscrew=1e-5; %Pa s %Beclimb=1e5; %Pa s - really big %Bline=1e-4*min(Bscrew,Bedge); -Bedge=1; -Bscrew=10; -Beclimb=1e10; -Bline=1e-4*min(Bscrew,Bedge); +Bedge = 1; +Bscrew = 10; +Beclimb = 1e10; +Bline = 1e-4 * min(Bscrew, Bedge); %Meshing -maxconnections=4; -lmax =0.25/amag; -lmin = 0.1/amag; -areamin=lmin*lmin*sin(60/180*pi)*0.5; -areamax=20*areamin; -doremesh=1; %flat set to 0 or 1 that turns the remesh functions off or on -docollision=1; %flat set to 0 or 1 that turns collision detection off or on -doseparation=1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on -dovirtmesh=1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on +maxconnections = 4; +lmax = 0.25 / amag; +lmin = 0.1 / amag; +areamin = lmin * lmin * sin(60/180 * pi) * 0.5; +areamax = 20 * areamin; +doremesh = 1; %flat set to 0 or 1 that turns the remesh functions off or on +docollision = 1; %flat set to 0 or 1 that turns collision detection off or on +doseparation = 1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on +dovirtmesh = 1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on %Simulation time -dt0=1E5; +dt0 = 1E5; intSimTime = 0; sinTime = 0; %dtplot=2E-9; %2ns -dtplot=1E6; -doplot=1; % frame recording: 1 == on, 0 == off +dtplot = 1E6; +doplot = 1; % frame recording: 1 == on, 0 == off totalSimTime = 1E6; curstep = 0; simTime = 0; %Integrator -integrator='int_trapezoid'; +integrator = 'int_trapezoid'; %integrator='int_trapezoid_stoc'; %in development -a=lmin/sqrt(3)*0.5; -Ec = MU/(4*pi)*log(a/0.1); -rann = 0.5*a; -rntol = 0.5*rann; % need to do convergence studies on all these parameters +a = lmin / sqrt(3) * 0.5; +Ec = MU / (4 * pi) * log(a / 0.1); +rann = 0.5 * a; +rntol = 0.5 * rann; % need to do convergence studies on all these parameters rmax = lmax; %Plotting -plotfreq=5; -plim=12/amag; %12microns -viewangle=[-35,15]; -printfreq=1; -printnode=2; - +plotFreq = 5; +plim = 12 / amag; %12microns +viewangle = [-35, 15]; +printfreq = 1; +printnode = 2; diff --git a/input/input101profiler.m b/input/input101profiler.m index 2718c10c..0d6796e4 100644 --- a/input/input101profiler.m +++ b/input/input101profiler.m @@ -23,36 +23,36 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clear all %% SOURCE GENERATION PARAMETERS -amag=3.18e-4; -mumag = 160E3; % MPa only used for plotting +amag = 3.18e-4; +mumag = 160E3; % MPa only used for plotting CRYSTAL_STRUCTURE = 'bcc'; NUM_SOURCES = 50; -DIST_SOURCE = 0.5/amag; +DIST_SOURCE = 0.5 / amag; %% FEM PARAMETERS %Cantilever -dx=30/amag; %10micron -dy=5/amag; %2micron -dz=5/amag; %2micron - -mx=30; % number of elements along beam length -loading=1; -vertices = [0,0,0;... - dx,0,0;... - 0,dy,0;... - dx,dy,0;... - 0,0,dz;... - dx,0,dz;... - 0,dy,dz;... - dx,dy,dz]; +dx = 30 / amag; %10micron +dy = 5 / amag; %2micron +dz = 5 / amag; %2micron + +mx = 30; % number of elements along beam length +loading = 1; +vertices = [0, 0, 0; ... + dx, 0, 0; ... + 0, dy, 0; ... + dx, dy, 0; ... + 0, 0, dz; ... + dx, 0, dz; ... + 0, dy, dz; ... + dx, dy, dz]; %% MATERIAL CONSTANTS %MU = 160E9; %160GPa MU = 1; -NU = 0.305; +NU = 0.305; %% DDLab PARAMETERS @@ -60,63 +60,62 @@ load('rnlinks_profilerGPU') %create mirror of prismatic loops (outside boundary) -rn_mirror = [rn(:,1)+dx , rn(:,2) , rn(:,3)+dx , zeros(length(rn(:,1)),1)+67]; +rn_mirror = [rn(:, 1) + dx, rn(:, 2), rn(:, 3) + dx, zeros(length(rn(:, 1)), 1) + 67]; links_mirror = links; -links_mirror(:,1) = links(:,2) + max(max(links(:,1:2))); -links_mirror(:,2) = links(:,1) + max(max(links(:,1:2))); +links_mirror(:, 1) = links(:, 2) + max(max(links(:, 1:2))); +links_mirror(:, 2) = links(:, 1) + max(max(links(:, 1:2))); -rn = vertcat(rn,rn_mirror); -links = vertcat(links,links_mirror); +rn = vertcat(rn, rn_mirror); +links = vertcat(links, links_mirror); %% %Edge and screw glide and climb mobility parameters -mobility='mobbcc1'; +mobility = 'mobbcc1'; global Bscrew Bedge Beclimb Bline %Bedge=1e-4; %Pa s %Bscrew=1e-5; %Pa s %Beclimb=1e5; %Pa s - really big %Bline=1e-4*min(Bscrew,Bedge); -Bedge=1; -Bscrew=10; -Beclimb=1e10; -Bline=1e-4*min(Bscrew,Bedge); +Bedge = 1; +Bscrew = 10; +Beclimb = 1e10; +Bline = 1e-4 * min(Bscrew, Bedge); %Meshing -maxconnections=4; -lmax =0.25/amag; -lmin = 0.1/amag; -areamin=lmin*lmin*sin(60/180*pi)*0.5; -areamax=20*areamin; -doremesh=1; %flat set to 0 or 1 that turns the remesh functions off or on -docollision=1; %flat set to 0 or 1 that turns collision detection off or on -doseparation=1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on -dovirtmesh=1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on +maxconnections = 4; +lmax = 0.25 / amag; +lmin = 0.1 / amag; +areamin = lmin * lmin * sin(60/180 * pi) * 0.5; +areamax = 20 * areamin; +doremesh = 1; %flat set to 0 or 1 that turns the remesh functions off or on +docollision = 1; %flat set to 0 or 1 that turns collision detection off or on +doseparation = 1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on +dovirtmesh = 1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on %Simulation time -dt0=1E5; +dt0 = 1E5; intSimTime = 0; sinTime = 0; %dtplot=2E-9; %2ns -dtplot=1E6; -doplot=1; % frame recording: 1 == on, 0 == off +dtplot = 1E6; +doplot = 1; % frame recording: 1 == on, 0 == off totalSimTime = 1E6; curstep = 0; simTime = 0; %Integrator -integrator='int_trapezoid'; +integrator = 'int_trapezoid'; %integrator='int_trapezoid_stoc'; %in development -a=lmin/sqrt(3)*0.5; -Ec = MU/(4*pi)*log(a/0.1); -rann = 0.5*a; -rntol = 0.5*rann; % need to do convergence studies on all these parameters +a = lmin / sqrt(3) * 0.5; +Ec = MU / (4 * pi) * log(a / 0.1); +rann = 0.5 * a; +rntol = 0.5 * rann; % need to do convergence studies on all these parameters rmax = lmax; %Plotting -plotfreq=10; -plim=12/amag; %12microns -viewangle=[-35,15]; -printfreq=1; -printnode=2; - +plotFreq = 10; +plim = 12 / amag; %12microns +viewangle = [-35, 15]; +printfreq = 1; +printnode = 2; diff --git a/input/input101profilerbis.m b/input/input101profilerbis.m index 610bff06..37feed89 100644 --- a/input/input101profilerbis.m +++ b/input/input101profilerbis.m @@ -23,36 +23,36 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clear all %% SOURCE GENERATION PARAMETERS -amag=3.18e-4; -mumag = 160E3; % MPa only used for plotting +amag = 3.18e-4; +mumag = 160E3; % MPa only used for plotting CRYSTAL_STRUCTURE = 'bcc'; NUM_SOURCES = 75; -DIST_SOURCE = 0.5/amag; +DIST_SOURCE = 0.5 / amag; %% FEM PARAMETERS %Cantilever -dx=30/amag; %10micron -dy=5/amag; %2micron -dz=5/amag; %2micron - -mx=30; % number of elements along beam length -loading=1; -vertices = [0,0,0;... - dx,0,0;... - 0,dy,0;... - dx,dy,0;... - 0,0,dz;... - dx,0,dz;... - 0,dy,dz;... - dx,dy,dz]; +dx = 30 / amag; %10micron +dy = 5 / amag; %2micron +dz = 5 / amag; %2micron + +mx = 30; % number of elements along beam length +loading = 1; +vertices = [0, 0, 0; ... + dx, 0, 0; ... + 0, dy, 0; ... + dx, dy, 0; ... + 0, 0, dz; ... + dx, 0, dz; ... + 0, dy, dz; ... + dx, dy, dz]; %% MATERIAL CONSTANTS %MU = 160E9; %160GPa MU = 1; -NU = 0.305; +NU = 0.305; %% DDLab PARAMETERS @@ -61,63 +61,62 @@ load('rnlinks_profilerbisGPU') %create mirror of prismatic loops (outside boundary) -rn_mirror = [rn(:,1)+dx , rn(:,2) , rn(:,3)+dx , zeros(length(rn(:,1)),1)+67]; +rn_mirror = [rn(:, 1) + dx, rn(:, 2), rn(:, 3) + dx, zeros(length(rn(:, 1)), 1) + 67]; links_mirror = links; -links_mirror(:,1) = links(:,2) + max(max(links(:,1:2))); -links_mirror(:,2) = links(:,1) + max(max(links(:,1:2))); +links_mirror(:, 1) = links(:, 2) + max(max(links(:, 1:2))); +links_mirror(:, 2) = links(:, 1) + max(max(links(:, 1:2))); -rn = vertcat(rn,rn_mirror); -links = vertcat(links,links_mirror); +rn = vertcat(rn, rn_mirror); +links = vertcat(links, links_mirror); %% %Edge and screw glide and climb mobility parameters -mobility='mobbcc1'; +mobility = 'mobbcc1'; global Bscrew Bedge Beclimb Bline %Bedge=1e-4; %Pa s %Bscrew=1e-5; %Pa s %Beclimb=1e5; %Pa s - really big %Bline=1e-4*min(Bscrew,Bedge); -Bedge=1; -Bscrew=10; -Beclimb=1e10; -Bline=1e-4*min(Bscrew,Bedge); +Bedge = 1; +Bscrew = 10; +Beclimb = 1e10; +Bline = 1e-4 * min(Bscrew, Bedge); %Meshing -maxconnections=4; -lmax =0.25/amag; -lmin = 0.1/amag; -areamin=lmin*lmin*sin(60/180*pi)*0.5; -areamax=20*areamin; -doremesh=1; %flat set to 0 or 1 that turns the remesh functions off or on -docollision=1; %flat set to 0 or 1 that turns collision detection off or on -doseparation=1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on -dovirtmesh=1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on +maxconnections = 4; +lmax = 0.25 / amag; +lmin = 0.1 / amag; +areamin = lmin * lmin * sin(60/180 * pi) * 0.5; +areamax = 20 * areamin; +doremesh = 1; %flat set to 0 or 1 that turns the remesh functions off or on +docollision = 1; %flat set to 0 or 1 that turns collision detection off or on +doseparation = 1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on +dovirtmesh = 1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on %Simulation time -dt0=1E5; +dt0 = 1E5; intSimTime = 0; sinTime = 0; %dtplot=2E-9; %2ns -dtplot=1E6; -doplot=1; % frame recording: 1 == on, 0 == off +dtplot = 1E6; +doplot = 1; % frame recording: 1 == on, 0 == off totalSimTime = 1E6; curstep = 0; simTime = 0; %Integrator -integrator='int_trapezoid'; +integrator = 'int_trapezoid'; %integrator='int_trapezoid_stoc'; %in development -a=lmin/sqrt(3)*0.5; -Ec = MU/(4*pi)*log(a/0.1); -rann = 0.5*a; -rntol = 0.5*rann; % need to do convergence studies on all these parameters +a = lmin / sqrt(3) * 0.5; +Ec = MU / (4 * pi) * log(a / 0.1); +rann = 0.5 * a; +rntol = 0.5 * rann; % need to do convergence studies on all these parameters rmax = lmax; %Plotting -plotfreq=10; -plim=12/amag; %12microns -viewangle=[-35,15]; -printfreq=1; -printnode=2; - +plotFreq = 10; +plim = 12 / amag; %12microns +viewangle = [-35, 15]; +printfreq = 1; +printnode = 2; diff --git a/input/input101profilerbis2.m b/input/input101profilerbis2.m index e74df347..3b705ed7 100644 --- a/input/input101profilerbis2.m +++ b/input/input101profilerbis2.m @@ -23,36 +23,36 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clear all %% SOURCE GENERATION PARAMETERS -amag=3.18e-4; -mumag = 160E3; % MPa only used for plotting +amag = 3.18e-4; +mumag = 160E3; % MPa only used for plotting CRYSTAL_STRUCTURE = 'bcc'; NUM_SOURCES = 160; -DIST_SOURCE = 0.5/amag; +DIST_SOURCE = 0.5 / amag; %% FEM PARAMETERS %Cantilever -dx=30/amag; %10micron -dy=5/amag; %2micron -dz=5/amag; %2micron - -mx=30; % number of elements along beam length -loading=1; -vertices = [0,0,0;... - dx,0,0;... - 0,dy,0;... - dx,dy,0;... - 0,0,dz;... - dx,0,dz;... - 0,dy,dz;... - dx,dy,dz]; +dx = 30 / amag; %10micron +dy = 5 / amag; %2micron +dz = 5 / amag; %2micron + +mx = 30; % number of elements along beam length +loading = 1; +vertices = [0, 0, 0; ... + dx, 0, 0; ... + 0, dy, 0; ... + dx, dy, 0; ... + 0, 0, dz; ... + dx, 0, dz; ... + 0, dy, dz; ... + dx, dy, dz]; %% MATERIAL CONSTANTS %MU = 160E9; %160GPa MU = 1; -NU = 0.305; +NU = 0.305; %% DDLab PARAMETERS @@ -64,60 +64,59 @@ % links_mirror = links; % links_mirror(:,1) = links(:,2) + max(max(links(:,1:2))); % links_mirror(:,2) = links(:,1) + max(max(links(:,1:2))); -% +% % rn = vertcat(rn,rn_mirror); % links = vertcat(links,links_mirror); load('rnlinks_profilerbis2'); %% %Edge and screw glide and climb mobility parameters -mobility='mobbcc1'; +mobility = 'mobbcc1'; global Bscrew Bedge Beclimb Bline %Bedge=1e-4; %Pa s %Bscrew=1e-5; %Pa s %Beclimb=1e5; %Pa s - really big %Bline=1e-4*min(Bscrew,Bedge); -Bedge=1; -Bscrew=10; -Beclimb=1e10; -Bline=1e-4*min(Bscrew,Bedge); +Bedge = 1; +Bscrew = 10; +Beclimb = 1e10; +Bline = 1e-4 * min(Bscrew, Bedge); %Meshing -maxconnections=4; -lmax =0.25/amag; -lmin = 0.1/amag; -areamin=lmin*lmin*sin(60/180*pi)*0.5; -areamax=20*areamin; -doremesh=1; %flat set to 0 or 1 that turns the remesh functions off or on -docollision=1; %flat set to 0 or 1 that turns collision detection off or on -doseparation=1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on -dovirtmesh=1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on +maxconnections = 4; +lmax = 0.25 / amag; +lmin = 0.1 / amag; +areamin = lmin * lmin * sin(60/180 * pi) * 0.5; +areamax = 20 * areamin; +doremesh = 1; %flat set to 0 or 1 that turns the remesh functions off or on +docollision = 1; %flat set to 0 or 1 that turns collision detection off or on +doseparation = 1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on +dovirtmesh = 1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on %Simulation time -dt0=1E5; +dt0 = 1E5; intSimTime = 0; sinTime = 0; %dtplot=2E-9; %2ns -dtplot=1E6; -doplot=1; % frame recording: 1 == on, 0 == off +dtplot = 1E6; +doplot = 1; % frame recording: 1 == on, 0 == off totalSimTime = 1E6; curstep = 0; simTime = 0; %Integrator -integrator='int_trapezoid'; +integrator = 'int_trapezoid'; %integrator='int_trapezoid_stoc'; %in development -a=lmin/sqrt(3)*0.5; -Ec = MU/(4*pi)*log(a/0.1); -rann = 0.5*a; -rntol = 0.5*rann; % need to do convergence studies on all these parameters +a = lmin / sqrt(3) * 0.5; +Ec = MU / (4 * pi) * log(a / 0.1); +rann = 0.5 * a; +rntol = 0.5 * rann; % need to do convergence studies on all these parameters rmax = lmax; %Plotting -plotfreq=10; -plim=12/amag; %12microns -viewangle=[-35,15]; -printfreq=1; -printnode=2; - +plotFreq = 10; +plim = 12 / amag; %12microns +viewangle = [-35, 15]; +printfreq = 1; +printnode = 2; diff --git a/input/input101profilerfull.m b/input/input101profilerfull.m index f93e28b5..0fa78a67 100644 --- a/input/input101profilerfull.m +++ b/input/input101profilerfull.m @@ -23,36 +23,36 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clear all %% SOURCE GENERATION PARAMETERS -amag=3.18e-4; -mumag = 160E3; % MPa only used for plotting +amag = 3.18e-4; +mumag = 160E3; % MPa only used for plotting CRYSTAL_STRUCTURE = 'bcc'; NUM_SOURCES = 370; -DIST_SOURCE = 0.5/amag; +DIST_SOURCE = 0.5 / amag; %% FEM PARAMETERS %Cantilever -dx=30/amag; %10micron -dy=5/amag; %2micron -dz=5/amag; %2micron - -mx=30; % number of elements along beam length -loading=1; -vertices = [0,0,0;... - dx,0,0;... - 0,dy,0;... - dx,dy,0;... - 0,0,dz;... - dx,0,dz;... - 0,dy,dz;... - dx,dy,dz]; +dx = 30 / amag; %10micron +dy = 5 / amag; %2micron +dz = 5 / amag; %2micron + +mx = 30; % number of elements along beam length +loading = 1; +vertices = [0, 0, 0; ... + dx, 0, 0; ... + 0, dy, 0; ... + dx, dy, 0; ... + 0, 0, dz; ... + dx, 0, dz; ... + 0, dy, dz; ... + dx, dy, dz]; %% MATERIAL CONSTANTS %MU = 160E9; %160GPa MU = 1; -NU = 0.305; +NU = 0.305; %% DDLab PARAMETERS @@ -60,65 +60,65 @@ %Dislocation nodes and segments generator % [rn,links] = checkGenerator101(NUM_SOURCES,DIST_SOURCE,CRYSTAL_STRUCTURE,dx,dy,dz); -% +% % %create mirror of prismatic loops (outside boundary) % rn_mirror = [rn(:,1)+dx , rn(:,2) , rn(:,3)+dx , zeros(length(rn(:,1)),1)+67]; % links_mirror = links; % links_mirror(:,1) = links(:,2) + max(max(links(:,1:2))); % links_mirror(:,2) = links(:,1) + max(max(links(:,1:2))); -% +% % rn = vertcat(rn,rn_mirror); % links = vertcat(links,links_mirror); %% %Edge and screw glide and climb mobility parameters -mobility='mobbcc1'; +mobility = 'mobbcc1'; global Bscrew Bedge Beclimb Bline %Bedge=1e-4; %Pa s %Bscrew=1e-5; %Pa s %Beclimb=1e5; %Pa s - really big %Bline=1e-4*min(Bscrew,Bedge); -Bedge=1; -Bscrew=10; -Beclimb=1e10; -Bline=1e-4*min(Bscrew,Bedge); +Bedge = 1; +Bscrew = 10; +Beclimb = 1e10; +Bline = 1e-4 * min(Bscrew, Bedge); %Meshing -maxconnections=4; -lmax =0.25/amag; -lmin = 0.1/amag; -areamin=lmin*lmin*sin(60/180*pi)*0.5; -areamax=20*areamin; -doremesh=1; %flat set to 0 or 1 that turns the remesh functions off or on -docollision=1; %flat set to 0 or 1 that turns collision detection off or on -doseparation=1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on -dovirtmesh=1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on +maxconnections = 4; +lmax = 0.25 / amag; +lmin = 0.1 / amag; +areamin = lmin * lmin * sin(60/180 * pi) * 0.5; +areamax = 20 * areamin; +doremesh = 1; %flat set to 0 or 1 that turns the remesh functions off or on +docollision = 1; %flat set to 0 or 1 that turns collision detection off or on +doseparation = 1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on +dovirtmesh = 1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on %Simulation time -dt0=1E5; +dt0 = 1E5; intSimTime = 0; sinTime = 0; %dtplot=2E-9; %2ns -dtplot=1E6; -doplot=1; % frame recording: 1 == on, 0 == off +dtplot = 1E6; +doplot = 1; % frame recording: 1 == on, 0 == off totalSimTime = 1E6; curstep = 0; simTime = 0; %Integrator -integrator='int_trapezoid'; +integrator = 'int_trapezoid'; %integrator='int_trapezoid_stoc'; %in development -a=lmin/sqrt(3)*0.5; -Ec = MU/(4*pi)*log(a/0.1); -rann = 0.5*a; -rntol = 0.5*rann; % need to do convergence studies on all these parameters +a = lmin / sqrt(3) * 0.5; +Ec = MU / (4 * pi) * log(a / 0.1); +rann = 0.5 * a; +rntol = 0.5 * rann; % need to do convergence studies on all these parameters rmax = lmax; %Plotting -plotfreq=10; -plim=12/amag; %12microns -viewangle=[-35,15]; -printfreq=1; -printnode=2; -plotfreq=200; +plotFreq = 10; +plim = 12 / amag; %12microns +viewangle = [-35, 15]; +printfreq = 1; +printnode = 2; +plotFreq = 200; diff --git a/input/input101simple.m b/input/input101simple.m index 61fd1db5..f0163ed6 100644 --- a/input/input101simple.m +++ b/input/input101simple.m @@ -23,100 +23,99 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clear all %% SOURCE GENERATION PARAMETERS -amag=3.18e-4; -mumag = 160E3; % MPa only used for plotting +amag = 3.18e-4; +mumag = 160E3; % MPa only used for plotting CRYSTAL_STRUCTURE = 'bcc'; NUM_SOURCES = 50; -DIST_SOURCE = 0.5/amag; +DIST_SOURCE = 0.5 / amag; %% FEM PARAMETERS %Cantilever -dx=6/amag; -dy=0.75/amag; -dz=0.75/amag; - -mx=15; % number of elements along beam length -loading=1; -vertices = [0,0,0;... - dx,0,0;... - 0,dy,0;... - dx,dy,0;... - 0,0,dz;... - dx,0,dz;... - 0,dy,dz;... - dx,dy,dz]; +dx = 6 / amag; +dy = 0.75 / amag; +dz = 0.75 / amag; + +mx = 15; % number of elements along beam length +loading = 1; +vertices = [0, 0, 0; ... + dx, 0, 0; ... + 0, dy, 0; ... + dx, dy, 0; ... + 0, 0, dz; ... + dx, 0, dz; ... + 0, dy, dz; ... + dx, dy, dz]; %% MATERIAL CONSTANTS %MU = 160E9; %160GPa MU = 1; -NU = 0.305; +NU = 0.305; %% DDLab PARAMETERS %Dislocation nodes and segments generator -[rn,links] = checkGenerator101(NUM_SOURCES,DIST_SOURCE,CRYSTAL_STRUCTURE,dx,dy,dz); +[rn, links] = checkGenerator101(NUM_SOURCES, DIST_SOURCE, CRYSTAL_STRUCTURE, dx, dy, dz); %create mirror of prismatic loops (outside boundary) -rn_mirror = [rn(:,1)+dx , rn(:,2) , rn(:,3)+dx , zeros(length(rn(:,1)),1)+67]; +rn_mirror = [rn(:, 1) + dx, rn(:, 2), rn(:, 3) + dx, zeros(length(rn(:, 1)), 1) + 67]; links_mirror = links; -links_mirror(:,1) = links(:,2) + max(max(links(:,1:2))); -links_mirror(:,2) = links(:,1) + max(max(links(:,1:2))); +links_mirror(:, 1) = links(:, 2) + max(max(links(:, 1:2))); +links_mirror(:, 2) = links(:, 1) + max(max(links(:, 1:2))); -rn = vertcat(rn,rn_mirror); -links = vertcat(links,links_mirror); +rn = vertcat(rn, rn_mirror); +links = vertcat(links, links_mirror); %% %Edge and screw glide and climb mobility parameters -mobility='mobbcc1'; +mobility = 'mobbcc1'; global Bscrew Bedge Beclimb Bline %Bedge=1e-4; %Pa s %Bscrew=1e-5; %Pa s %Beclimb=1e5; %Pa s - really big %Bline=1e-4*min(Bscrew,Bedge); -Bedge=1; -Bscrew=10; -Beclimb=1e10; -Bline=1e-4*min(Bscrew,Bedge); +Bedge = 1; +Bscrew = 10; +Beclimb = 1e10; +Bline = 1e-4 * min(Bscrew, Bedge); %Meshing -maxconnections=4; -lmax =0.25/amag; -lmin = 0.1/amag; -areamin=lmin*lmin*sin(60/180*pi)*0.5; -areamax=20*areamin; -doremesh=1; %flat set to 0 or 1 that turns the remesh functions off or on -docollision=1; %flat set to 0 or 1 that turns collision detection off or on -doseparation=1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on -dovirtmesh=1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on +maxconnections = 4; +lmax = 0.25 / amag; +lmin = 0.1 / amag; +areamin = lmin * lmin * sin(60/180 * pi) * 0.5; +areamax = 20 * areamin; +doremesh = 1; %flat set to 0 or 1 that turns the remesh functions off or on +docollision = 1; %flat set to 0 or 1 that turns collision detection off or on +doseparation = 1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on +dovirtmesh = 1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on %Simulation time -dt0=1E5; +dt0 = 1E5; intSimTime = 0; sinTime = 0; %dtplot=2E-9; %2ns -dtplot=1E6; -doplot=1; % frame recording: 1 == on, 0 == off -totalSimTime = 1E5; +dtplot = 1E6; +doplot = 1; % frame recording: 1 == on, 0 == off +totalSimTime = 1E5; curstep = 0; simTime = 0; %Integrator -integrator='int_trapezoid'; +integrator = 'int_trapezoid'; %integrator='int_trapezoid_stoc'; %in development -a=lmin/sqrt(3)*0.5; -Ec = MU/(4*pi)*log(a/0.1); -rann = 0.5*a; -rntol = 0.5*rann; % need to do convergence studies on all these parameters +a = lmin / sqrt(3) * 0.5; +Ec = MU / (4 * pi) * log(a / 0.1); +rann = 0.5 * a; +rntol = 0.5 * rann; % need to do convergence studies on all these parameters rmax = lmax; %Plotting -plotfreq=10; -plim=12/amag; %12microns -viewangle=[45,45]; -printfreq=1; -printnode=2; - +plotFreq = 10; +plim = 12 / amag; %12microns +viewangle = [45, 45]; +printfreq = 1; +printnode = 2; diff --git a/input/input111_Cu.m b/input/input111_Cu.m index 8ce2396b..0b9fecaa 100644 --- a/input/input111_Cu.m +++ b/input/input111_Cu.m @@ -23,99 +23,98 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clear all %% SOURCE GENERATION PARAMETERS -amag=3.61e-4; -mumag = 48E3; % MPa only used for plotting +amag = 3.61e-4; +mumag = 48E3; % MPa only used for plotting CRYSTAL_STRUCTURE = 'fcc'; NUM_SOURCES = 100; -DIST_SOURCE = 0.5/amag; +DIST_SOURCE = 0.5 / amag; %% FEM PARAMETERS %Cantilever -dx=12.3/amag; %12.3micron -dy=3.58/amag; %3.58micron -dz=2.2458/amag; %2.2458micron - -mx=10; % number of elements along beam length -loading=1; -vertices = [0,0,0;... - dx,0,0;... - 0,dy,0;... - dx,dy,0;... - 0,0,dz;... - dx,0,dz;... - 0,dy,dz;... - dx,dy,dz]; +dx = 12.3 / amag; %12.3micron +dy = 3.58 / amag; %3.58micron +dz = 2.2458 / amag; %2.2458micron + +mx = 10; % number of elements along beam length +loading = 1; +vertices = [0, 0, 0; ... + dx, 0, 0; ... + 0, dy, 0; ... + dx, dy, 0; ... + 0, 0, dz; ... + dx, 0, dz; ... + 0, dy, dz; ... + dx, dy, dz]; %% MATERIAL CONSTANTS MU = 1; -NU = 0.36; +NU = 0.36; %% DDLab PARAMETERS %Dislocation nodes and segments generator -[rn,links] = checkGenerator111(NUM_SOURCES,DIST_SOURCE,CRYSTAL_STRUCTURE,dx,dy,dz); +[rn, links] = checkGenerator111(NUM_SOURCES, DIST_SOURCE, CRYSTAL_STRUCTURE, dx, dy, dz); %create mirror of prismatic loops (outside boundary) -rn_mirror = [rn(:,1)+dx , rn(:,2) , rn(:,3)+dx , zeros(length(rn(:,1)),1)+67]; +rn_mirror = [rn(:, 1) + dx, rn(:, 2), rn(:, 3) + dx, zeros(length(rn(:, 1)), 1) + 67]; links_mirror = links; -links_mirror(:,1) = links(:,2) + max(max(links(:,1:2))); -links_mirror(:,2) = links(:,1) + max(max(links(:,1:2))); +links_mirror(:, 1) = links(:, 2) + max(max(links(:, 1:2))); +links_mirror(:, 2) = links(:, 1) + max(max(links(:, 1:2))); -rn = vertcat(rn,rn_mirror); -links = vertcat(links,links_mirror); +rn = vertcat(rn, rn_mirror); +links = vertcat(links, links_mirror); %% %Edge and screw glide and climb mobility parameters -mobility='mobfcc0'; +mobility = 'mobfcc0'; global Bscrew Bedge Beclimb Bline %Bedge=1e-4; %Pa s %Bscrew=1e-5; %Pa s %Beclimb=1e5; %Pa s - really big %Bline=1e-4*min(Bscrew,Bedge); -Bedge=1; -Bscrew=10; -Beclimb=1e8; -Bline=1e-4*min(Bscrew,Bedge); +Bedge = 1; +Bscrew = 10; +Beclimb = 1e8; +Bline = 1e-4 * min(Bscrew, Bedge); %Meshing -maxconnections=4; -lmax =0.125/amag; -lmin = 0.05/amag; -areamin=lmin*lmin*sin(60/180*pi)*0.5; -areamax=20*areamin; -doremesh=1; %flat set to 0 or 1 that turns the remesh functions off or on -docollision=1; %flat set to 0 or 1 that turns collision detection off or on -doseparation=1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on -dovirtmesh=1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on +maxconnections = 4; +lmax = 0.125 / amag; +lmin = 0.05 / amag; +areamin = lmin * lmin * sin(60/180 * pi) * 0.5; +areamax = 20 * areamin; +doremesh = 1; %flat set to 0 or 1 that turns the remesh functions off or on +docollision = 1; %flat set to 0 or 1 that turns collision detection off or on +doseparation = 1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on +dovirtmesh = 1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on %Simulation time -dt0=1E5; +dt0 = 1E5; intSimTime = 0; sinTime = 0; %dtplot=2E-9; %2ns -dtplot=1E6; -doplot=1; % frame recording: 1 == on, 0 == off +dtplot = 1E6; +doplot = 1; % frame recording: 1 == on, 0 == off totalSimTime = 1E12; curstep = 0; simTime = 0; %Integrator -integrator='int_trapezoid'; +integrator = 'int_trapezoid'; %integrator='int_trapezoid_stoc'; %in development -a=lmin/sqrt(3)*0.5; -Ec = MU/(4*pi)*log(a/0.1); -rann = 0.5*a; -rntol = 0.5*rann; % need to do convergence studies on all these parameters +a = lmin / sqrt(3) * 0.5; +Ec = MU / (4 * pi) * log(a / 0.1); +rann = 0.5 * a; +rntol = 0.5 * rann; % need to do convergence studies on all these parameters rmax = lmax; %Plotting -plotfreq=10; -plim=12/amag; %12microns -viewangle=[-35,15]; -printfreq=1; -printnode=2; - +plotFreq = 10; +plim = 12 / amag; %12microns +viewangle = [-35, 15]; +printfreq = 1; +printnode = 2; diff --git a/input/input2loops.m b/input/input2loops.m index 5cd46db7..9db58095 100644 --- a/input/input2loops.m +++ b/input/input2loops.m @@ -23,106 +23,105 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clear all %% SOURCE GENERATION PARAMETERS -amag=3.18e-4; -mumag = 160E3; % MPa only used for plotting +amag = 3.18e-4; +mumag = 160E3; % MPa only used for plotting CRYSTAL_STRUCTURE = 'bcc'; NUM_SOURCES = 1; -DIST_SOURCE = 0.5/amag; +DIST_SOURCE = 0.5 / amag; %% FEM PARAMETERS %Cantilever -dx=30/amag; %10micron -dy=5/amag; %2micron -dz=5/amag; %2micron - -mx=30; % number of elements along beam length -loading=1; -vertices = [0,0,0;... - dx,0,0;... - 0,dy,0;... - dx,dy,0;... - 0,0,dz;... - dx,0,dz;... - 0,dy,dz;... - dx,dy,dz]; +dx = 30 / amag; %10micron +dy = 5 / amag; %2micron +dz = 5 / amag; %2micron + +mx = 30; % number of elements along beam length +loading = 1; +vertices = [0, 0, 0; ... + dx, 0, 0; ... + 0, dy, 0; ... + dx, dy, 0; ... + 0, 0, dz; ... + dx, 0, dz; ... + 0, dy, dz; ... + dx, dy, dz]; %% MATERIAL CONSTANTS %MU = 160E9; %160GPa MU = 1; -NU = 0.305; +NU = 0.305; %% DDLab PARAMETERS %Dislocation nodes and segments generator -[rn,links] = checkGenerator101(NUM_SOURCES,DIST_SOURCE,CRYSTAL_STRUCTURE,dx,dy,dz); - rn2=rn; - rn2(:,1)=rn(:,1)+1.5*DIST_SOURCE; %translating of the second loop - rn2(:,3)=rn(:,3)+1.5*DIST_SOURCE; - rn=[rn ; rn2]; %rn concatenation - load('2loopslinks'); %links loading - links(:,3:5)=-links(:,3:5); +[rn, links] = checkGenerator101(NUM_SOURCES, DIST_SOURCE, CRYSTAL_STRUCTURE, dx, dy, dz); +rn2 = rn; +rn2(:, 1) = rn(:, 1) + 1.5 * DIST_SOURCE; %translating of the second loop +rn2(:, 3) = rn(:, 3) + 1.5 * DIST_SOURCE; +rn = [rn; rn2]; %rn concatenation +load('2loopslinks'); %links loading +links(:, 3:5) = -links(:, 3:5); %create mirror of prismatic loops (outside boundary) % rn_mirror = [rn(:,1)+dx , rn(:,2) , rn(:,3)+dx , zeros(length(rn(:,1)),1)+67]; % links_mirror = links; % links_mirror(:,1) = links(:,2) + max(max(links(:,1:2))); % links_mirror(:,2) = links(:,1) + max(max(links(:,1:2))); -% +% % rn = vertcat(rn,rn_mirror); % links = vertcat(links,links_mirror); %% %Edge and screw glide and climb mobility parameters -mobility='mobbcc1'; +mobility = 'mobbcc1'; global Bscrew Bedge Beclimb Bline %Bedge=1e-4; %Pa s %Bscrew=1e-5; %Pa s %Beclimb=1e5; %Pa s - really big %Bline=1e-4*min(Bscrew,Bedge); -Bedge=1; -Bscrew=10; -Beclimb=1e10; -Bline=1e-4*min(Bscrew,Bedge); +Bedge = 1; +Bscrew = 10; +Beclimb = 1e10; +Bline = 1e-4 * min(Bscrew, Bedge); %Meshing -maxconnections=4; -lmax =0.25/amag; -lmin = 0.1/amag; -areamin=lmin*lmin*sin(60/180*pi)*0.5; -areamax=20*areamin; -doremesh=1; %flat set to 0 or 1 that turns the remesh functions off or on -docollision=1; %flat set to 0 or 1 that turns collision detection off or on -doseparation=1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on -dovirtmesh=1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on +maxconnections = 4; +lmax = 0.25 / amag; +lmin = 0.1 / amag; +areamin = lmin * lmin * sin(60/180 * pi) * 0.5; +areamax = 20 * areamin; +doremesh = 1; %flat set to 0 or 1 that turns the remesh functions off or on +docollision = 1; %flat set to 0 or 1 that turns collision detection off or on +doseparation = 1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on +dovirtmesh = 1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on %Simulation time -dt0=1E5; +dt0 = 1E5; intSimTime = 0; sinTime = 0; %dtplot=2E-9; %2ns -dtplot=1E6; -doplot=1; % frame recording: 1 == on, 0 == off -totalSimTime = 1E7; +dtplot = 1E6; +doplot = 1; % frame recording: 1 == on, 0 == off +totalSimTime = 1E7; curstep = 0; simTime = 0; %Integrator -integrator='int_trapezoid'; +integrator = 'int_trapezoid'; %integrator='int_trapezoid_stoc'; %in development -a=lmin/sqrt(3)*0.5; -Ec = MU/(4*pi)*log(a/0.1); -rann = 0.5*a; -rntol = 0.5*rann; % need to do convergence studies on all these parameters +a = lmin / sqrt(3) * 0.5; +Ec = MU / (4 * pi) * log(a / 0.1); +rann = 0.5 * a; +rntol = 0.5 * rann; % need to do convergence studies on all these parameters rmax = lmax; %Plotting -plotfreq=2; -plim=12/amag; %12microns -viewangle=[10,45]; -printfreq=1; -printnode=2; - +plotFreq = 2; +plim = 12 / amag; %12microns +viewangle = [10, 45]; +printfreq = 1; +printnode = 2; diff --git a/input/inputCheck.m b/input/inputCheck.m index 23312dec..c7ce5975 100644 --- a/input/inputCheck.m +++ b/input/inputCheck.m @@ -23,92 +23,92 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clear all %% SOURCE GENERATION PARAMETERS -bmag=1e-4; -mumag = 1;%160E3; % MPa only used for plotting +bmag = 1e-4; +mumag = 1; %160E3;% MPa only used for plotting CRYSTAL_STRUCTURE = 'bcc'; NUM_SOURCES = 20; -DIST_SOURCE = 0.5/bmag; +DIST_SOURCE = 0.5 / bmag; %% FEM PARAMETERS %Cantilever -dx=10/bmag; %10micron -dy=2/bmag; %2micron -dz=2/bmag; %2micron +dx = 10 / bmag; %10micron +dy = 2 / bmag; %2micron +dz = 2 / bmag; %2micron -mx=30; % number of elements along beam length -loading=1; -vertices = [0,0,0;... - dx,0,0;... - 0,dy,0;... - dx,dy,0;... - 0,0,dz;... - dx,0,dz;... - 0,dy,dz;... - dx,dy,dz]; +mx = 30; % number of elements along beam length +loading = 1; +vertices = [0, 0, 0; ... + dx, 0, 0; ... + 0, dy, 0; ... + dx, dy, 0; ... + 0, 0, dz; ... + dx, 0, dz; ... + 0, dy, dz; ... + dx, dy, dz]; %% MATERIAL CONSTANTS %MU = 160E9; %160GPa MU = 1; -NU = 0.305; +NU = 0.305; %% DDLab PARAMETERS %Dislocation nodes and segments generator -[rn,links] = checkGenerator101(NUM_SOURCES,DIST_SOURCE,CRYSTAL_STRUCTURE,dx,dy,dz); +[rn, links] = checkGenerator101(NUM_SOURCES, DIST_SOURCE, CRYSTAL_STRUCTURE, dx, dy, dz); %rn(:,1:3) = rn(:,1:3)+dx/mx*0.25; %% %Edge and screw glide and climb mobility parameters -mobility='mobbcc1'; +mobility = 'mobbcc1'; global Bscrew Bedge Beclimb Bline %Bedge=1e-4; %Pa s %Bscrew=1e-5; %Pa s %Beclimb=1e5; %Pa s - really big %Bline=1e-4*min(Bscrew,Bedge); -Bedge=1; -Bscrew=10; -Beclimb=1e10; -Bline=1e-4*min(Bscrew,Bedge); +Bedge = 1; +Bscrew = 10; +Beclimb = 1e10; +Bline = 1e-4 * min(Bscrew, Bedge); %Meshing -maxconnections=4; -lmax =0.5/bmag; %1 microns -lmin = lmax/10; % 0.05 microns -areamin=lmin*lmin*sin(60/180*pi)*0.5; -areamax=20*areamin; -doremesh=1; %flat set to 0 or 1 that turns the remesh functions off or on -docollision=1; %flat set to 0 or 1 that turns collision detection off or on -doseparation=1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on -dovirtmesh=1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on +maxconnections = 4; +lmax = 0.5 / bmag; %1 microns +lmin = lmax / 10; % 0.05 microns +areamin = lmin * lmin * sin(60/180 * pi) * 0.5; +areamax = 20 * areamin; +doremesh = 1; %flat set to 0 or 1 that turns the remesh functions off or on +docollision = 1; %flat set to 0 or 1 that turns collision detection off or on +doseparation = 1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on +dovirtmesh = 1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on %Simulation time %dt0=10E-9; %1 ns -dt0=1E9; +dt0 = 1E9; intSimTime = 0; sinTime = 0; %dtplot=2E-9; %2ns -dtplot=1E9; -doplot=1; % frame recording: 1 == on, 0 == off +dtplot = 1E9; +doplot = 1; % frame recording: 1 == on, 0 == off totalSimTime = 1E12; curstep = 0; simTime = 0; %Integrator -integrator='int_trapezoid'; +integrator = 'int_trapezoid'; %integrator='int_trapezoid_stoc'; %in development -a=lmin/sqrt(3)*0.5; -Ec = MU/(4*pi)*log(a/0.1); -rann = 0.5*a; -rntol = 0.5*rann; % need to do convergence studies on all these parameters +a = lmin / sqrt(3) * 0.5; +Ec = MU / (4 * pi) * log(a / 0.1); +rann = 0.5 * a; +rntol = 0.5 * rann; % need to do convergence studies on all these parameters rmax = lmax; %Plotting -plotfreq=10; -plim=12/bmag; %12microns -viewangle=[-35,15]; -printfreq=1; -printnode=2; \ No newline at end of file +plotFreq = 10; +plim = 12 / bmag; %12microns +viewangle = [-35, 15]; +printfreq = 1; +printnode = 2; diff --git a/input/inputCheck2.m b/input/inputCheck2.m index ab674dc7..091f409e 100644 --- a/input/inputCheck2.m +++ b/input/inputCheck2.m @@ -23,43 +23,43 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clear all %% SOURCE GENERATION PARAMETERS -bmag=1e-4; -mumag = 1;%160E3; % MPa only used for plotting +bmag = 1e-4; +mumag = 1; %160E3;% MPa only used for plotting CRYSTAL_STRUCTURE = 'bcc'; NUM_SOURCES = 1; -DIST_SOURCE = 2.5/bmag; +DIST_SOURCE = 2.5 / bmag; %% FEM PARAMETERS %Cantilever -dx=30/bmag; %10micron -dy=5/bmag; %2micron -dz=5/bmag; %2micron - -mx=50; % number of elements along beam length -loading=1; -vertices = [0,0,0;... - dx,0,0;... - 0,dy,0;... - dx,dy,0;... - 0,0,dz;... - dx,0,dz;... - 0,dy,dz;... - dx,dy,dz]; - +dx = 30 / bmag; %10micron +dy = 5 / bmag; %2micron +dz = 5 / bmag; %2micron + +mx = 50; % number of elements along beam length +loading = 1; +vertices = [0, 0, 0; ... + dx, 0, 0; ... + 0, dy, 0; ... + dx, dy, 0; ... + 0, 0, dz; ... + dx, 0, dz; ... + 0, dy, dz; ... + dx, dy, dz]; + %% MATERIAL CONSTANTS %MU = 160E9; %160GPa MU = 1; -NU = 0.305; +NU = 0.305; %% DDLab PARAMETERS %Dislocation nodes and segments generator -[rn,links] = checkGenerator(NUM_SOURCES,DIST_SOURCE,CRYSTAL_STRUCTURE,dx,dy,dz); +[rn, links] = checkGenerator(NUM_SOURCES, DIST_SOURCE, CRYSTAL_STRUCTURE, dx, dy, dz); -midPTS(1,:) = [0.1*dx,0.2*dy,0.5*dz]; +midPTS(1, :) = [0.1 * dx, 0.2 * dy, 0.5 * dz]; normal = [0.01 0.99 0]; % generate random <111> b vector % b_vec = pmone(normal,NUM_SOURCES); @@ -69,98 +69,98 @@ %We try a loop placed within the slip-plane (shear loop)... % seg_vec = cross(normal',b_vec'); -edge = 0.5*[0.01 0 -0.99]*DIST_SOURCE; -screw = 0.5*[0.99 0.01 0] *DIST_SOURCE; +edge = 0.5 * [0.01 0 -0.99] * DIST_SOURCE; +screw = 0.5 * [0.99 0.01 0] * DIST_SOURCE; -rn = zeros(3,4); -links = zeros(2,8); +rn = zeros(3, 4); +links = zeros(2, 8); - % pure edge segment -% r1 = midPTS(p,:) +% pure edge segment +% r1 = midPTS(p,:) % r2 = midPTS(p,:) + 0.5*DIST_SOURCE*seg_vec(p,:)/norm(seg_vec(p,:)); % r3 = midPTS(p,:) + 1*DIST_SOURCE*seg_vec(p,:)/norm(seg_vec(p,:)); -% - % pure screw segment -% r1 = midPTS(p,:) - 0.5*DIST_SOURCE*b_vec(p,:)/norm(b_vec(p,:)); +% +% pure screw segment +% r1 = midPTS(p,:) - 0.5*DIST_SOURCE*b_vec(p,:)/norm(b_vec(p,:)); % r2 = midPTS(p,:); % r3 = midPTS(p,:) + 0.5*DIST_SOURCE*b_vec(p,:)/norm(b_vec(p,:)); - -r1 = midPTS(1,:)-edge; -r2 = midPTS(1,:); -r3 = midPTS(1,:) + edge; + +r1 = midPTS(1, :) - edge; +r2 = midPTS(1, :); +r3 = midPTS(1, :) + edge; r4 = r3 + screw; r5 = r4 + screw; r6 = r5 - edge; r7 = r6 - edge; r8 = r7 - screw; -rn(1,:) = [r1 7]; -rn(2,:) = [r2 0]; -rn(3,:) = [r3 7]; -rn(4,:) = [r4 0]; -rn(5,:) = [r5 7]; -rn(6,:) = [r6 0]; -rn(7,:) = [r7 7]; -rn(8,:) = [r8 0]; +rn(1, :) = [r1 7]; +rn(2, :) = [r2 0]; +rn(3, :) = [r3 7]; +rn(4, :) = [r4 0]; +rn(5, :) = [r5 7]; +rn(6, :) = [r6 0]; +rn(7, :) = [r7 7]; +rn(8, :) = [r8 0]; for p = 1:7 - links(p,1:2) = [p, p+1]; + links(p, 1:2) = [p, p + 1]; end -links(8,1:2) = [8,1]; -links(1:8,3:5) = repmat(b_vec,8,1); -links(1:8,6:8) = repmat(normal,8,1); +links(8, 1:2) = [8, 1]; +links(1:8, 3:5) = repmat(b_vec, 8, 1); +links(1:8, 6:8) = repmat(normal, 8, 1); %% %Edge and screw glide and climb mobility parameters -mobility='mobbcc1'; +mobility = 'mobbcc1'; global Bscrew Bedge Beclimb Bline %Bedge=1e-4; %Pa s %Bscrew=1e-5; %Pa s %Beclimb=1e5; %Pa s - really big %Bline=1e-4*min(Bscrew,Bedge); -Bedge=1; -Bscrew=10; -Beclimb=1e10; -Bline=1e-4*min(Bscrew,Bedge); +Bedge = 1; +Bscrew = 10; +Beclimb = 1e10; +Bline = 1e-4 * min(Bscrew, Bedge); %Meshing -maxconnections=4; -lmax =0.5/bmag; %1 microns -lmin = lmax/10; % 0.05 microns -areamin=lmin*lmin*sin(60/180*pi)*0.5; -areamax=20*areamin; -doremesh=1; %flat set to 0 or 1 that turns the remesh functions off or on -docollision=1; %flat set to 0 or 1 that turns collision detection off or on -doseparation=1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on -dovirtmesh=1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on +maxconnections = 4; +lmax = 0.5 / bmag; %1 microns +lmin = lmax / 10; % 0.05 microns +areamin = lmin * lmin * sin(60/180 * pi) * 0.5; +areamax = 20 * areamin; +doremesh = 1; %flat set to 0 or 1 that turns the remesh functions off or on +docollision = 1; %flat set to 0 or 1 that turns collision detection off or on +doseparation = 1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on +dovirtmesh = 1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on %Simulation time %dt0=10E-9; %1 ns -dt0=1E9; +dt0 = 1E9; intSimTime = 0; sinTime = 0; %dtplot=2E-9; %2ns -dtplot=1E9; -doplot=1; % frame recording: 1 == on, 0 == off +dtplot = 1E9; +doplot = 1; % frame recording: 1 == on, 0 == off totalSimTime = 1E12; curstep = 0; simTime = 0; %Integrator -integrator='int_trapezoid'; +integrator = 'int_trapezoid'; %integrator='int_trapezoid_stoc'; %in development -a=lmin/sqrt(3)*0.5; -Ec = MU/(4*pi)*log(a/0.1); -rann = 0.5*a; -rntol = 0.5*rann; % need to do convergence studies on all these parameters +a = lmin / sqrt(3) * 0.5; +Ec = MU / (4 * pi) * log(a / 0.1); +rann = 0.5 * a; +rntol = 0.5 * rann; % need to do convergence studies on all these parameters rmax = lmax; %Plotting -plotfreq=10; -plim=12/bmag; %12microns -viewangle=[-35,15]; -printfreq=1; -printnode=2; \ No newline at end of file +plotFreq = 10; +plim = 12 / bmag; %12microns +viewangle = [-35, 15]; +printfreq = 1; +printnode = 2; diff --git a/input/inputFRS.m b/input/inputFRS.m index a218db01..ccd7596c 100644 --- a/input/inputFRS.m +++ b/input/inputFRS.m @@ -24,91 +24,90 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clear all %% SOURCE GENERATION PARAMETERS -a_mag=3.14E-4; -mumag = 160E3; % MPa only used for plotting +a_mag = 3.14E-4; +mumag = 160E3; % MPa only used for plotting CRYSTAL_STRUCTURE = 'bcc'; NUM_SOURCES = 30; -DIST_SOURCE = 0.5/a_mag; +DIST_SOURCE = 0.5 / a_mag; %% FEM PARAMETERS %Cantilever -dx=30/a_mag; %10micron -dy=5/a_mag; %2micron -dz=5/a_mag; %2micron - -mx=30; % number of elements along beam length -loading=1; -vertices = [0,0,0;... - dx,0,0;... - 0,dy,0;... - dx,dy,0;... - 0,0,dz;... - dx,0,dz;... - 0,dy,dz;... - dx,dy,dz]; +dx = 30 / a_mag; %10micron +dy = 5 / a_mag; %2micron +dz = 5 / a_mag; %2micron + +mx = 30; % number of elements along beam length +loading = 1; +vertices = [0, 0, 0; ... + dx, 0, 0; ... + 0, dy, 0; ... + dx, dy, 0; ... + 0, 0, dz; ... + dx, 0, dz; ... + 0, dy, dz; ... + dx, dy, dz]; %% MATERIAL CONSTANTS %MU = 160E9; %160GPa MU = 1; -NU = 0.305; +NU = 0.305; %% DDLab PARAMETERS %Dislocation nodes and segments generator -[rn,links] = FRSGenerator(NUM_SOURCES,DIST_SOURCE,CRYSTAL_STRUCTURE,0.5*dx,dy,dz); +[rn, links] = FRSGenerator(NUM_SOURCES, DIST_SOURCE, CRYSTAL_STRUCTURE, 0.5 * dx, dy, dz); %Edge and screw glide and climb mobility parameters -mobility='mobbcc0'; +mobility = 'mobbcc0'; global Bscrew Bedge Beclimb Bline %Bedge=1e-4; %Pa s %Bscrew=1e-5; %Pa s %Beclimb=1e5; %Pa s - really big %Bline=1e-4*min(Bscrew,Bedge); -Bedge=1; -Bscrew=1; -Beclimb=1e10; -Bline=1e-4*min(Bscrew,Bedge); +Bedge = 1; +Bscrew = 1; +Beclimb = 1e10; +Bline = 1e-4 * min(Bscrew, Bedge); %Meshing -maxconnections=4; -lmax =0.5/a_mag; %1 microns -lmin = lmax/5; % 0.1 microns -areamin=lmin*lmin*sin(60/180*pi)*0.5; -areamax=20*areamin; -doremesh=1; %flat set to 0 or 1 that turns the remesh functions off or on -docollision=1; %flat set to 0 or 1 that turns collision detection off or on -doseparation=1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on -dovirtmesh=1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on +maxconnections = 4; +lmax = 0.5 / a_mag; %1 microns +lmin = lmax / 5; % 0.1 microns +areamin = lmin * lmin * sin(60/180 * pi) * 0.5; +areamax = 20 * areamin; +doremesh = 1; %flat set to 0 or 1 that turns the remesh functions off or on +docollision = 1; %flat set to 0 or 1 that turns collision detection off or on +doseparation = 1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on +dovirtmesh = 1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on %Simulation time %dt0=10E-9; %1 ns -dt0=1E7; +dt0 = 1E7; intSimTime = 0; sinTime = 0; %dtplot=2E-9; %2ns -dtplot=1E9; -doplot=1; % frame recording: 1 == on, 0 == off +dtplot = 1E9; +doplot = 1; % frame recording: 1 == on, 0 == off totalSimTime = 1E12; curstep = 0; simTime = 0; %Integrator -integrator='int_trapezoid'; +integrator = 'int_trapezoid'; %integrator='int_trapezoid_stoc'; %in development -a=lmin/sqrt(3)*0.5; -Ec = MU/(4*pi)*log(a/0.1); -rann = 0.5*a; -rntol = 0.5*rann; % need to do convergence studies on all these parameters +a = lmin / sqrt(3) * 0.5; +Ec = MU / (4 * pi) * log(a / 0.1); +rann = 0.5 * a; +rntol = 0.5 * rann; % need to do convergence studies on all these parameters rmax = lmax; %Plotting -plotfreq=100; -plim=12/a_mag; %12microns -viewangle=[-35,15]; -printfreq=1; -printnode=2; - +plotFreq = 100; +plim = 12 / a_mag; %12microns +viewangle = [-35, 15]; +printfreq = 1; +printnode = 2; diff --git a/input/input_indentation_v1rotatebcc.m b/input/input_indentation_v1rotatebcc.m index cf96a1dc..d71bc8c9 100644 --- a/input/input_indentation_v1rotatebcc.m +++ b/input/input_indentation_v1rotatebcc.m @@ -159,12 +159,12 @@ burgsref(find(abs(burgsref) < eps)) = 0; %Plotting -plotfreq = 100; +plotFreq = 100; savefreq = 50; plim = 12 / amag; %12microns viewangle2 = [-81, 81]; viewangle = [-25, 40]; -printfreq = plotfreq; +printfreq = plotFreq; printnode = 2; %Dislocation nodes and segments generator diff --git a/input/inputbccHY.m b/input/inputbccHY.m index 1cb04389..8e9f1f05 100644 --- a/input/inputbccHY.m +++ b/input/inputbccHY.m @@ -25,50 +25,50 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clear all %% SOURCE GENERATION PARAMETERS -amag = 2.856e-4; -LENGTH_b = sqrt(3)/2; -mumag = 82E3; % MPa only used for plotting +amag = 2.856e-4; +LENGTH_b = sqrt(3) / 2; +mumag = 82E3; % MPa only used for plotting CRYSTAL_STRUCTURE = 'bcc'; NUM_SOURCES = 10; -DIST_SOURCE = 0.2/amag; -LENGTH_SOURCE = 500*LENGTH_b; +DIST_SOURCE = 0.2 / amag; +LENGTH_SOURCE = 500 * LENGTH_b; %% FEM PARAMETERS %Cantilever -dx=12/amag; %10micron=10/amag -dy=3/amag; % -dz=3/amag; % +dx = 12 / amag; %10micron=10/amag +dy = 3 / amag; % +dz = 3 / amag; % % dx=30/amag; %10micron=10/amag % dy=5/amag; % % dz=5/amag; % -mx=50; % number of elements along beam length -loading=1; -vertices = [0,0,0;... - dx,0,0;... - 0,dy,0;... - dx,dy,0;... - 0,0,dz;... - dx,0,dz;... - 0,dy,dz;... - dx,dy,dz]; +mx = 50; % number of elements along beam length +loading = 1; +vertices = [0, 0, 0; ... + dx, 0, 0; ... + 0, dy, 0; ... + dx, dy, 0; ... + 0, 0, dz; ... + dx, 0, dz; ... + 0, dy, dz; ... + dx, dy, dz]; %% DDLab PARAMETERS %Edge and screw glide and climb mobility parameters -mobility='mobbcc1'; +mobility = 'mobbcc1'; global Bscrew Bedge Beclimb Bline %Bedge=1e-4; %Pa s %Bscrew=1e-5; %Pa s %Beclimb=1e5; %Pa s - really big %Bline=1e-4*min(Bscrew,Bedge); -Bedge=5E-4; -Bscrew=100e-4; -Beclimb=1e5; -Bline=1e-4*min(Bscrew,Bedge); +Bedge = 5E-4; +Bscrew = 100e-4; +Beclimb = 1e5; +Bline = 1e-4 * min(Bscrew, Bedge); global cOVERa global MU NU maxSeg @@ -92,61 +92,60 @@ NU = 0.29; %Plotting -plotfreq=500; -savefreq=10; -plim=12/amag; %12microns -% viewangle=[0,0]; -viewangle=[30,60]; -printfreq=1000; -printnode=2; +plotFreq = 500; +savefreq = 10; +plim = 12 / amag; %12microns +% viewangle=[0,0]; +viewangle = [30, 60]; +printfreq = 1000; +printnode = 2; %Dislocation nodes and segments generator -[rn,links] = checkGeneratorbccHY(NUM_SOURCES,DIST_SOURCE,CRYSTAL_STRUCTURE,dx,dy,dz,plim,LENGTH_SOURCE); - +[rn, links] = checkGeneratorbccHY(NUM_SOURCES, DIST_SOURCE, CRYSTAL_STRUCTURE, dx, dy, dz, plim, LENGTH_SOURCE); %create mirror of prismatic loops (outside boundary) % rn_mirror = [rn(:,1)+dx , rn(:,2) , rn(:,3)+dx , zeros(length(rn(:,1)),1)+67]; % links_mirror = links; % links_mirror(:,1) = links(:,2) + max(max(links(:,1:2))); % links_mirror(:,2) = links(:,1) + max(max(links(:,1:2))); -% +% % rn = vertcat(rn,rn_mirror); % links = vertcat(links,links_mirror); %HY20180112: ^^^^initial dislocation structures^^^^ %Meshing -maxconnections=4; -lmax =0.1/amag; -lmin = 0.02/amag; -areamin=lmin*lmin*sin(60/180*pi)*0.5; -areamax=20*areamin; +maxconnections = 4; +lmax = 0.1 / amag; +lmin = 0.02 / amag; +areamin = lmin * lmin * sin(60/180 * pi) * 0.5; +areamax = 20 * areamin; dosave = 0; -doremesh=1; %flat set to 0 or 1 that turns the remesh functions off or on -docollision=1; %flat set to 0 or 1 that turns collision detection off or on -doseparation=1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on -dovirtmesh=1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on +doremesh = 1; %flat set to 0 or 1 that turns the remesh functions off or on +docollision = 1; %flat set to 0 or 1 that turns collision detection off or on +doseparation = 1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on +dovirtmesh = 1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on %Simulation time -dt0=1E8; -dt=1E8; +dt0 = 1E8; +dt = 1E8; intSimTime = 0; sinTime = 0; %dtplot=2E-9; %2ns -dtplot=0; -doplot=1; % frame recording: 1 == on, 0 == off +dtplot = 0; +doplot = 1; % frame recording: 1 == on, 0 == off totalSimTime = 1E15; curstep = 0; simTime = 0; %Integrator -integrator='int_trapezoid'; +integrator = 'int_trapezoid'; %integrator='int_trapezoid_stoc'; %in development -% a=lmin/sqrt(3)*0.5; -a = 40*LENGTH_b; -Ec = MU/(4*pi)*log(a/0.1); -rann = 0.5*a; -rntol = 0.5*rann; % need to do convergence studies on all these parameters +% a=lmin/sqrt(3)*0.5; +a = 40 * LENGTH_b; +Ec = MU / (4 * pi) * log(a / 0.1); +rann = 0.5 * a; +rntol = 0.5 * rann; % need to do convergence studies on all these parameters rmax = lmax; maxSeg = lmax; @@ -160,21 +159,20 @@ %HY20180320: hydrogen related parameters %HY20180409: corrected hydrogen related parameters % delta_VH =0.0907; -delta_VH = 1.4E-12/amag/amag/amag; -k_BH = 1.38E-23*1E6/amag*1E6/(amag*amag*mumag); +delta_VH = 1.4E-12 / amag / amag / amag; +k_BH = 1.38E-23 * 1E6 / amag * 1E6 / (amag * amag * mumag); TH = 300; -c_max = 8.46E28*1E-18/(1/amag)^3;%HY20180409: N_L=8.46E28/m^3 in bcc steel +c_max = 8.46E28 * 1E-18 / (1 / amag)^3; %HY20180409: N_L=8.46E28/m^3 in bcc steel % kappa_remote = 1E-6;%HY20180408: corresponding to 1appm in bcc steel -kappa_remote = 1E-7;%HY20180409: corresponding to 0.1appm in bcc steel +kappa_remote = 1E-7; %HY20180409: corresponding to 0.1appm in bcc steel % kappa_remote = 0; -potential_remote = log(1/kappa_remote-1)*k_BH*TH; +potential_remote = log(1 / kappa_remote - 1) * k_BH * TH; % tpause = 1E-6*1E-3/(Bedge/mumag); rn00 = rn; links00 = links; - tpause = 1.8E10; use_gpu = 1; n_threads = 256; diff --git a/input/inputsquareloop.m b/input/inputsquareloop.m index f2c0516e..9c079197 100644 --- a/input/inputsquareloop.m +++ b/input/inputsquareloop.m @@ -23,124 +23,122 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clear all %% SOURCE GENERATION PARAMETERS -amag=3.18e-4; -mumag = 135E3; % MPa only used for plotting +amag = 3.18e-4; +mumag = 135E3; % MPa only used for plotting CRYSTAL_STRUCTURE = 'bcc'; NUM_SOURCES = 1; -DIST_SOURCE = 0.5/amag; +DIST_SOURCE = 0.5 / amag; %% FEM PARAMETERS %Cantilever -dx=19.5/amag; %10micron -dy=5.4/amag; %2micron -dz=5.3/amag; %2micron - -mx=40; % number of elements along beam length -loading=1; -vertices = [0,0,0;... - dx,0,0;... - 0,dy,0;... - dx,dy,0;... - 0,0,dz;... - dx,0,dz;... - 0,dy,dz;... - dx,dy,dz]; +dx = 19.5 / amag; %10micron +dy = 5.4 / amag; %2micron +dz = 5.3 / amag; %2micron + +mx = 40; % number of elements along beam length +loading = 1; +vertices = [0, 0, 0; ... + dx, 0, 0; ... + 0, dy, 0; ... + dx, dy, 0; ... + 0, 0, dz; ... + dx, 0, dz; ... + 0, dy, dz; ... + dx, dy, dz]; %% MATERIAL CONSTANTS %MU = 160E9; %160GPa MU = 1; -NU = 0.28; +NU = 0.28; %% DDLab PARAMETERS -c=1/amag; -x=0.5/(amag*sqrt(6)); -y=0.5/(amag*sqrt(3)); - -rn=[ 2*c 2.5*c+2*x-y 0.5*c 0; - 2*c+x 2.5*c-y 0.5*c+x 0; - 2*c+2*x 2.5*c-2*x-y 0.5*c+2*x 0; - 2*c+2*x+y 2.5*c-2*x 0.5*c+2*x+y 0; - 2*c+2*x+2*y 2.5*c-2*x+y 0.5*c+2*x+2*y 0; - 2*c+x+2*y 2.5*c+y 0.5*c+x+2*y 0; - 2*c+2*y 2.5*c+2*x+y 0.5*c+2*y 0; - 2*c+y 2.5*c+2*x 0.5*c+y 0]; - -b1=[-1 -1 -1]/sqrt(3); -n1=[-1 0 1]/sqrt(2); -n2=[1 0 -1]/sqrt(2); - -links=[1 2 b1 n1; - 2 3 b1 n1; - 3 4 b1 n1; - 4 5 b1 n1; - 5 6 b1 n1; - 6 7 b1 n1; - 7 8 b1 n1; - 8 1 b1 n1]; - +c = 1 / amag; +x = 0.5 / (amag * sqrt(6)); +y = 0.5 / (amag * sqrt(3)); + +rn = [2 * c 2.5 * c + 2 * x - y 0.5 * c 0; + 2 * c + x 2.5 * c - y 0.5 * c + x 0; + 2 * c + 2 * x 2.5 * c - 2 * x - y 0.5 * c + 2 * x 0; + 2 * c + 2 * x + y 2.5 * c - 2 * x 0.5 * c + 2 * x + y 0; + 2 * c + 2 * x + 2 * y 2.5 * c - 2 * x + y 0.5 * c + 2 * x + 2 * y 0; + 2 * c + x + 2 * y 2.5 * c + y 0.5 * c + x + 2 * y 0; + 2 * c + 2 * y 2.5 * c + 2 * x + y 0.5 * c + 2 * y 0; + 2 * c + y 2.5 * c + 2 * x 0.5 * c + y 0]; + +b1 = [-1 -1 -1] / sqrt(3); +n1 = [-1 0 1] / sqrt(2); +n2 = [1 0 -1] / sqrt(2); + +links = [1 2 b1 n1; + 2 3 b1 n1; + 3 4 b1 n1; + 4 5 b1 n1; + 5 6 b1 n1; + 6 7 b1 n1; + 7 8 b1 n1; + 8 1 b1 n1]; %create mirror of prismatic loops (outside boundary) % rn_mirror = [rn(:,1)+dx , rn(:,2) , rn(:,3)+dx , zeros(length(rn(:,1)),1)+67]; % links_mirror = links; % links_mirror(:,1) = links(:,2) + max(max(links(:,1:2))); % links_mirror(:,2) = links(:,1) + max(max(links(:,1:2))); -% +% % rn = vertcat(rn,rn_mirror); % links = vertcat(links,links_mirror); %% %Edge and screw glide and climb mobility parameters -mobility='mobbcc_bb'; +mobility = 'mobbcc_bb'; global Bscrew Bedge Beclimb Bline %Bedge=1e-4; %Pa s %Bscrew=1e-5; %Pa s %Beclimb=1e5; %Pa s - really big %Bline=1e-4*min(Bscrew,Bedge); -Bedge=1; -Bscrew=100; -Beclimb=1e5; -Bline=20e-4*min(Bscrew,Bedge); +Bedge = 1; +Bscrew = 100; +Beclimb = 1e5; +Bline = 20e-4 * min(Bscrew, Bedge); %Meshing -maxconnections=4; -lmax =0.25/amag; -lmin = 0.05/amag; -areamin=lmin*lmin*sin(60/180*pi)*0.5; -areamax=20*areamin; -doremesh=1; %flat set to 0 or 1 that turns the remesh functions off or on -docollision=1; %flat set to 0 or 1 that turns collision detection off or on -doseparation=1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on -dovirtmesh=1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on +maxconnections = 4; +lmax = 0.25 / amag; +lmin = 0.05 / amag; +areamin = lmin * lmin * sin(60/180 * pi) * 0.5; +areamax = 20 * areamin; +doremesh = 1; %flat set to 0 or 1 that turns the remesh functions off or on +docollision = 1; %flat set to 0 or 1 that turns collision detection off or on +doseparation = 1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on +dovirtmesh = 1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on %Simulation time -dt0=2.048e9; +dt0 = 2.048e9; intSimTime = 0; %sinTime = 0; %dtplot=2E-9; %2ns -dtplot=5E4; -doplot=1; % frame recording: 1 == on, 0 == off +dtplot = 5E4; +doplot = 1; % frame recording: 1 == on, 0 == off totalSimTime = 3.3608e12; curstep = 0; simTime = 0; %Integrator -integrator='int_trapezoid_bb_old'; +integrator = 'int_trapezoid_bb_old'; %integrator='int_trapezoid_stoc'; %in development -a=(lmin/sqrt(3)*0.5)/4; -Ec = MU/(4*pi)*log(a/0.1); -rann = 2*a; -rntol = 0.5*rann*100; % need to do convergence studies on all these parameters -rmax = 0.5*lmin; +a = (lmin / sqrt(3) * 0.5) / 4; +Ec = MU / (4 * pi) * log(a / 0.1); +rann = 2 * a; +rntol = 0.5 * rann * 100; % need to do convergence studies on all these parameters +rmax = 0.5 * lmin; %Plotting -plotfreq=10; -plim=12/amag; %12microns -viewangle=[-35,15]; -printfreq=500; -printnode=2; - +plotFreq = 10; +plim = 12 / amag; %12microns +viewangle = [-35, 15]; +printfreq = 500; +printnode = 2; diff --git a/input/inputsquareloopcollision.m b/input/inputsquareloopcollision.m index c47eeac6..3193692f 100644 --- a/input/inputsquareloopcollision.m +++ b/input/inputsquareloopcollision.m @@ -38,7 +38,7 @@ dz = 5 / amag; %2micron mx = 20; % number of elements along beam length -loading = 1; +loading = 'displacementControl'; vertices = [0, 0, 0; ... dx, 0, 0; ... 0, dy, 0; ... @@ -154,7 +154,7 @@ % rmax = lmax; % %Plotting -% plotfreq = 20; +% plotFreq = 20; % plim = 12 / amag; %12microns % viewangle = [-35, 15]; % printfreq = 1; @@ -167,7 +167,7 @@ % totalSimTime = 1e9; % dt0 = 1e60; % printfreq = 100000; -% plotfreq = 1; +% plotFreq = 1; % Bedge = 1; % Bscrew = 10; % mobility = 'mobbcc_bb1b'; diff --git a/input/inputsquareloopcollision2.m b/input/inputsquareloopcollision2.m index a6046a72..9a5b54e2 100644 --- a/input/inputsquareloopcollision2.m +++ b/input/inputsquareloopcollision2.m @@ -23,141 +23,139 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clear all %% SOURCE GENERATION PARAMETERS -amag=3.18e-4; -mumag = 160E3; % MPa only used for plotting +amag = 3.18e-4; +mumag = 160E3; % MPa only used for plotting CRYSTAL_STRUCTURE = 'bcc'; NUM_SOURCES = 1; -DIST_SOURCE = 0.5/amag; +DIST_SOURCE = 0.5 / amag; %% FEM PARAMETERS %Cantilever -dx=30/amag; %10micron -dy=10/amag; %2micron -dz=10/amag; %2micron - -mx=20; % number of elements along beam length -loading=1; -vertices = [0,0,0;... - dx,0,0;... - 0,dy,0;... - dx,dy,0;... - 0,0,dz;... - dx,0,dz;... - 0,dy,dz;... - dx,dy,dz]; +dx = 30 / amag; %10micron +dy = 10 / amag; %2micron +dz = 10 / amag; %2micron + +mx = 20; % number of elements along beam length +loading = 1; +vertices = [0, 0, 0; ... + dx, 0, 0; ... + 0, dy, 0; ... + dx, dy, 0; ... + 0, 0, dz; ... + dx, 0, dz; ... + 0, dy, dz; ... + dx, dy, dz]; %% MATERIAL CONSTANTS %MU = 160E9; %160GPa MU = 1; -NU = 0.305; +NU = 0.305; %% DDLab PARAMETERS -c=1/amag; -x=0.5/(amag*sqrt(6)); -y=0.5/(amag*sqrt(3)); - -rn=[ 6*c 4.5*c+2*x-y 1.5*c 0; - 6*c+x 4.5*c-y 1.5*c+x 0; - 6*c+2*x 4.5*c-2*x-y 1.5*c+2*x 0; - 6*c+2*x+y 4.5*c-2*x 1.5*c+2*x+y 0; - 6*c+2*x+2*y 4.5*c-2*x+y 1.5*c+2*x+2*y 0; - 6*c+x+2*y 4.5*c+y 1.5*c+x+2*y 0; - 6*c+2*y 4.5*c+2*x+y 1.5*c+2*y 0; - 6*c+y 4.5*c+2*x 1.5*c+y 0; - 9*c 5.5*c+2*x-y 1.5*c 0; - 9*c-x 5.5*c-y 1.5*c+x 0; - 9*c-2*x 5.5*c-2*x-y 1.5*c+2*x 0; - 9*c-2*x-y 5.5*c-2*x 1.5*c+2*x+y 0; - 9*c-2*x-2*y 5.5*c-2*x+y 1.5*c+2*x+2*y 0; - 9*c-x-2*y 5.5*c+y 1.5*c+x+2*y 0; - 9*c-2*y 5.5*c+2*x+y 1.5*c+2*y 0; - 9*c-y 5.5*c+2*x 1.5*c+y 0]; - -b1=[-1 -1 -1]/sqrt(3); -b2=[-1 1 1]/sqrt(3); -n1=[-1 0 1]/sqrt(2); -n2=[1 0 1]/sqrt(2); - -links=[ 1 2 b1 n1; - 2 3 b1 n1; - 3 4 b1 n1; - 4 5 b1 n1; - 5 6 b1 n1; - 6 7 b1 n1; - 7 8 b1 n1; - 8 1 b1 n1; - 9 10 b2 n2; - 10 11 b2 n2; - 11 12 b2 n2; - 12 13 b2 n2; - 13 14 b2 n2; - 14 15 b2 n2; - 15 16 b2 n2; - 16 9 b2 n2]; - +c = 1 / amag; +x = 0.5 / (amag * sqrt(6)); +y = 0.5 / (amag * sqrt(3)); + +rn = [6 * c 4.5 * c + 2 * x - y 1.5 * c 0; + 6 * c + x 4.5 * c - y 1.5 * c + x 0; + 6 * c + 2 * x 4.5 * c - 2 * x - y 1.5 * c + 2 * x 0; + 6 * c + 2 * x + y 4.5 * c - 2 * x 1.5 * c + 2 * x + y 0; + 6 * c + 2 * x + 2 * y 4.5 * c - 2 * x + y 1.5 * c + 2 * x + 2 * y 0; + 6 * c + x + 2 * y 4.5 * c + y 1.5 * c + x + 2 * y 0; + 6 * c + 2 * y 4.5 * c + 2 * x + y 1.5 * c + 2 * y 0; + 6 * c + y 4.5 * c + 2 * x 1.5 * c + y 0; + 9 * c 5.5 * c + 2 * x - y 1.5 * c 0; + 9 * c - x 5.5 * c - y 1.5 * c + x 0; + 9 * c - 2 * x 5.5 * c - 2 * x - y 1.5 * c + 2 * x 0; + 9 * c - 2 * x - y 5.5 * c - 2 * x 1.5 * c + 2 * x + y 0; + 9 * c - 2 * x - 2 * y 5.5 * c - 2 * x + y 1.5 * c + 2 * x + 2 * y 0; + 9 * c - x - 2 * y 5.5 * c + y 1.5 * c + x + 2 * y 0; + 9 * c - 2 * y 5.5 * c + 2 * x + y 1.5 * c + 2 * y 0; + 9 * c - y 5.5 * c + 2 * x 1.5 * c + y 0]; + +b1 = [-1 -1 -1] / sqrt(3); +b2 = [-1 1 1] / sqrt(3); +n1 = [-1 0 1] / sqrt(2); +n2 = [1 0 1] / sqrt(2); + +links = [1 2 b1 n1; + 2 3 b1 n1; + 3 4 b1 n1; + 4 5 b1 n1; + 5 6 b1 n1; + 6 7 b1 n1; + 7 8 b1 n1; + 8 1 b1 n1; + 9 10 b2 n2; + 10 11 b2 n2; + 11 12 b2 n2; + 12 13 b2 n2; + 13 14 b2 n2; + 14 15 b2 n2; + 15 16 b2 n2; + 16 9 b2 n2]; %create mirror of prismatic loops (outside boundary) % rn_mirror = [rn(:,1)+dx , rn(:,2) , rn(:,3)+dx , zeros(length(rn(:,1)),1)+67]; % links_mirror = links; % links_mirror(:,1) = links(:,2) + max(max(links(:,1:2))); % links_mirror(:,2) = links(:,1) + max(max(links(:,1:2))); -% +% % rn = vertcat(rn,rn_mirror); % links = vertcat(links,links_mirror); %% %Edge and screw glide and climb mobility parameters -mobility='mobbcc1'; +mobility = 'mobbcc1'; global Bscrew Bedge Beclimb Bline %Bedge=1e-4; %Pa s %Bscrew=1e-5; %Pa s %Beclimb=1e5; %Pa s - really big %Bline=1e-4*min(Bscrew,Bedge); -Bedge=1; -Bscrew=10; -Beclimb=1e10; -Bline=1e-4*min(Bscrew,Bedge); +Bedge = 1; +Bscrew = 10; +Beclimb = 1e10; +Bline = 1e-4 * min(Bscrew, Bedge); %Meshing -maxconnections=4; -lmax =0.25/amag; -lmin = 0.1/amag; -areamin=lmin*lmin*sin(60/180*pi)*0.5; -areamax=20*areamin; -doremesh=1; %flat set to 0 or 1 that turns the remesh functions off or on -docollision=1; %flat set to 0 or 1 that turns collision detection off or on -doseparation=1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on -dovirtmesh=1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on +maxconnections = 4; +lmax = 0.25 / amag; +lmin = 0.1 / amag; +areamin = lmin * lmin * sin(60/180 * pi) * 0.5; +areamax = 20 * areamin; +doremesh = 1; %flat set to 0 or 1 that turns the remesh functions off or on +docollision = 1; %flat set to 0 or 1 that turns collision detection off or on +doseparation = 1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on +dovirtmesh = 1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on %Simulation time -dt0=1E5; +dt0 = 1E5; intSimTime = 0; sinTime = 0; %dtplot=2E-9; %2ns -dtplot=3E4; -doplot=1; % frame recording: 1 == on, 0 == off +dtplot = 3E4; +doplot = 1; % frame recording: 1 == on, 0 == off totalSimTime = 6E6; curstep = 0; simTime = 0; %Integrator -integrator='int_trapezoid'; +integrator = 'int_trapezoid'; %integrator='int_trapezoid_stoc'; %in development -a=lmin/sqrt(3)*0.5; -Ec = MU/(4*pi)*log(a/0.1); -rann = 0.5*a; -rntol = 0.5*rann; % need to do convergence studies on all these parameters +a = lmin / sqrt(3) * 0.5; +Ec = MU / (4 * pi) * log(a / 0.1); +rann = 0.5 * a; +rntol = 0.5 * rann; % need to do convergence studies on all these parameters rmax = lmax; %Plotting -plotfreq=5; -plim=12/amag; %12microns -viewangle=[-35,15]; -printfreq=1; -printnode=2; - +plotFreq = 5; +plim = 12 / amag; %12microns +viewangle = [-35, 15]; +printfreq = 1; +printnode = 2; diff --git a/input/inputsquareloopcollision_a.m b/input/inputsquareloopcollision_a.m index 8701135d..66377fcf 100644 --- a/input/inputsquareloopcollision_a.m +++ b/input/inputsquareloopcollision_a.m @@ -23,141 +23,139 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clear all %% SOURCE GENERATION PARAMETERS -amag=3.18e-4; -mumag = 160E3; % MPa only used for plotting +amag = 3.18e-4; +mumag = 160E3; % MPa only used for plotting CRYSTAL_STRUCTURE = 'bcc'; NUM_SOURCES = 1; -DIST_SOURCE = 0.5/amag; +DIST_SOURCE = 0.5 / amag; %% FEM PARAMETERS %Cantilever -dx=30/amag; %10micron -dy=5/amag; %2micron -dz=5/amag; %2micron - -mx=20; % number of elements along beam length -loading=1; -vertices = [0,0,0;... - dx,0,0;... - 0,dy,0;... - dx,dy,0;... - 0,0,dz;... - dx,0,dz;... - 0,dy,dz;... - dx,dy,dz]; +dx = 30 / amag; %10micron +dy = 5 / amag; %2micron +dz = 5 / amag; %2micron + +mx = 20; % number of elements along beam length +loading = 1; +vertices = [0, 0, 0; ... + dx, 0, 0; ... + 0, dy, 0; ... + dx, dy, 0; ... + 0, 0, dz; ... + dx, 0, dz; ... + 0, dy, dz; ... + dx, dy, dz]; %% MATERIAL CONSTANTS %MU = 160E9; %160GPa MU = 1; -NU = 0.305; +NU = 0.305; %% DDLab PARAMETERS -c=1/amag; -x=0.5/(amag*sqrt(6)); -y=0.5/(amag*sqrt(3)); - -rn=[ 6*c 2.5*c+2*x-y 0.5*c 0; - 6*c+x 2.5*c-y 0.5*c+x 0; - 6*c+2*x 2.5*c-2*x-y 0.5*c+2*x 0; - 6*c+2*x+y 2.5*c-2*x 0.5*c+2*x+y 0; - 6*c+2*x+2*y 2.5*c-2*x+y 0.5*c+2*x+2*y 0; - 6*c+x+2*y 2.5*c+y 0.5*c+x+2*y 0; - 6*c+2*y 2.5*c+2*x+y 0.5*c+2*y 0; - 6*c+y 2.5*c+2*x 0.5*c+y 0; - 8*c 2.5*c+2*x-y 0.5*c 0; - 8*c-x 2.5*c-y 0.5*c+x 0; - 8*c-2*x 2.5*c-2*x-y 0.5*c+2*x 0; - 8*c-2*x-y 2.5*c-2*x 0.5*c+2*x+y 0; - 8*c-2*x-2*y 2.5*c-2*x+y 0.5*c+2*x+2*y 0; - 8*c-x-2*y 2.5*c+y 0.5*c+x+2*y 0; - 8*c-2*y 2.5*c+2*x+y 0.5*c+2*y 0; - 8*c-y 2.5*c+2*x 0.5*c+y 0]; - -b1=[-1 -1 -1]/2; -b2=[-1 1 1]/2; -n1=[-1 0 1]/sqrt(2); -n2=[1 0 1]/sqrt(2); - -links=[ 1 2 b1 n1; - 2 3 b1 n1; - 3 4 b1 n1; - 4 5 b1 n1; - 5 6 b1 n1; - 6 7 b1 n1; - 7 8 b1 n1; - 8 1 b1 n1; - 9 10 b2 n2; - 10 11 b2 n2; - 11 12 b2 n2; - 12 13 b2 n2; - 13 14 b2 n2; - 14 15 b2 n2; - 15 16 b2 n2; - 16 9 b2 n2]; - +c = 1 / amag; +x = 0.5 / (amag * sqrt(6)); +y = 0.5 / (amag * sqrt(3)); + +rn = [6 * c 2.5 * c + 2 * x - y 0.5 * c 0; + 6 * c + x 2.5 * c - y 0.5 * c + x 0; + 6 * c + 2 * x 2.5 * c - 2 * x - y 0.5 * c + 2 * x 0; + 6 * c + 2 * x + y 2.5 * c - 2 * x 0.5 * c + 2 * x + y 0; + 6 * c + 2 * x + 2 * y 2.5 * c - 2 * x + y 0.5 * c + 2 * x + 2 * y 0; + 6 * c + x + 2 * y 2.5 * c + y 0.5 * c + x + 2 * y 0; + 6 * c + 2 * y 2.5 * c + 2 * x + y 0.5 * c + 2 * y 0; + 6 * c + y 2.5 * c + 2 * x 0.5 * c + y 0; + 8 * c 2.5 * c + 2 * x - y 0.5 * c 0; + 8 * c - x 2.5 * c - y 0.5 * c + x 0; + 8 * c - 2 * x 2.5 * c - 2 * x - y 0.5 * c + 2 * x 0; + 8 * c - 2 * x - y 2.5 * c - 2 * x 0.5 * c + 2 * x + y 0; + 8 * c - 2 * x - 2 * y 2.5 * c - 2 * x + y 0.5 * c + 2 * x + 2 * y 0; + 8 * c - x - 2 * y 2.5 * c + y 0.5 * c + x + 2 * y 0; + 8 * c - 2 * y 2.5 * c + 2 * x + y 0.5 * c + 2 * y 0; + 8 * c - y 2.5 * c + 2 * x 0.5 * c + y 0]; + +b1 = [-1 -1 -1] / 2; +b2 = [-1 1 1] / 2; +n1 = [-1 0 1] / sqrt(2); +n2 = [1 0 1] / sqrt(2); + +links = [1 2 b1 n1; + 2 3 b1 n1; + 3 4 b1 n1; + 4 5 b1 n1; + 5 6 b1 n1; + 6 7 b1 n1; + 7 8 b1 n1; + 8 1 b1 n1; + 9 10 b2 n2; + 10 11 b2 n2; + 11 12 b2 n2; + 12 13 b2 n2; + 13 14 b2 n2; + 14 15 b2 n2; + 15 16 b2 n2; + 16 9 b2 n2]; %create mirror of prismatic loops (outside boundary) % rn_mirror = [rn(:,1)+dx , rn(:,2) , rn(:,3)+dx , zeros(length(rn(:,1)),1)+67]; % links_mirror = links; % links_mirror(:,1) = links(:,2) + max(max(links(:,1:2))); % links_mirror(:,2) = links(:,1) + max(max(links(:,1:2))); -% +% % rn = vertcat(rn,rn_mirror); % links = vertcat(links,links_mirror); %% %Edge and screw glide and climb mobility parameters -mobility='mobbcc_bb1b'; +mobility = 'mobbcc_bb1b'; global Bscrew Bedge Beclimb Bline %Bedge=1e-4; %Pa s %Bscrew=1e-5; %Pa s %Beclimb=1e5; %Pa s - really big %Bline=1e-4*min(Bscrew,Bedge); -Bedge=1; -Bscrew=100; -Beclimb=1e10; -Bline=1e-4*min(Bscrew,Bedge); +Bedge = 1; +Bscrew = 100; +Beclimb = 1e10; +Bline = 1e-4 * min(Bscrew, Bedge); %Meshing -maxconnections=4; -lmax =0.25/amag; -lmin = 0.1/amag; -areamin=lmin*lmin*sin(60/180*pi)*0.5; -areamax=20*areamin; -doremesh=1; %flat set to 0 or 1 that turns the remesh functions off or on -docollision=1; %flat set to 0 or 1 that turns collision detection off or on -doseparation=1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on -dovirtmesh=1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on +maxconnections = 4; +lmax = 0.25 / amag; +lmin = 0.1 / amag; +areamin = lmin * lmin * sin(60/180 * pi) * 0.5; +areamax = 20 * areamin; +doremesh = 1; %flat set to 0 or 1 that turns the remesh functions off or on +docollision = 1; %flat set to 0 or 1 that turns collision detection off or on +doseparation = 1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on +dovirtmesh = 1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on %Simulation time -dt0=1E6; +dt0 = 1E6; intSimTime = 0; sinTime = 0; %dtplot=2E-9; %2ns -dtplot=3E4; -doplot=1; % frame recording: 1 == on, 0 == off -totalSimTime = 1E9;%6E6; +dtplot = 3E4; +doplot = 1; % frame recording: 1 == on, 0 == off +totalSimTime = 1E9; %6E6; curstep = 0; simTime = 0; %Integrator -integrator='int_trapezoid_bb_old'; +integrator = 'int_trapezoid_bb_old'; %integrator='int_trapezoid_stoc'; %in development -a=11.3473;%lmin/sqrt(3)*0.5; -Ec = MU/(4*pi)*log(a/0.1); -rann = 0.5*a; -rntol = 0.5*rann; % need to do convergence studies on all these parameters -rmax = 0.5*lmin; +a = 11.3473; %lmin/sqrt(3)*0.5; +Ec = MU / (4 * pi) * log(a / 0.1); +rann = 0.5 * a; +rntol = 0.5 * rann; % need to do convergence studies on all these parameters +rmax = 0.5 * lmin; %Plotting -plotfreq=1; -plim=12/amag; %12microns -viewangle=[-35,15]; -printfreq=1000000; -printnode=2; - +plotFreq = 1; +plim = 12 / amag; %12microns +viewangle = [-35, 15]; +printfreq = 1000000; +printnode = 2; diff --git a/input/inputsquareloopcrossslip.m b/input/inputsquareloopcrossslip.m index 20f4d609..1b187e95 100644 --- a/input/inputsquareloopcrossslip.m +++ b/input/inputsquareloopcrossslip.m @@ -23,128 +23,126 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clear all %% SOURCE GENERATION PARAMETERS -amag=3.18e-4; -mumag = 160E3; % MPa only used for plotting +amag = 3.18e-4; +mumag = 160E3; % MPa only used for plotting CRYSTAL_STRUCTURE = 'bcc'; NUM_SOURCES = 1; -DIST_SOURCE = 0.5/amag; +DIST_SOURCE = 0.5 / amag; %% FEM PARAMETERS %Cantilever -dx=30/amag; %10micron -dy=5/amag; %2micron -dz=5/amag; %2micron - -mx=20; % number of elements along beam length -loading=1; -vertices = [0,0,0;... - dx,0,0;... - 0,dy,0;... - dx,dy,0;... - 0,0,dz;... - dx,0,dz;... - 0,dy,dz;... - dx,dy,dz]; +dx = 30 / amag; %10micron +dy = 5 / amag; %2micron +dz = 5 / amag; %2micron + +mx = 20; % number of elements along beam length +loading = 1; +vertices = [0, 0, 0; ... + dx, 0, 0; ... + 0, dy, 0; ... + dx, dy, 0; ... + 0, 0, dz; ... + dx, 0, dz; ... + 0, dy, dz; ... + dx, dy, dz]; %% MATERIAL CONSTANTS %MU = 160E9; %160GPa MU = 1; -NU = 0.305; +NU = 0.305; %% DDLab PARAMETERS -c=1/amag; -x=0.5/(amag*sqrt(6)); -y=0.5/(amag*sqrt(3)); -z=0.5/(amag*sqrt(2)); - -rn=[ 2*c 2.5*c+2*x-y 0.5*c 0; - 2*c+x 2.5*c-y 0.5*c+x 0; - 2*c+2*x 2.5*c-2*x-y 0.5*c+2*x 0; - 2*c+2*x+y 2.5*c-2*x 0.5*c+2*x+y 0; - 2*c+2*x+2*y 2.5*c-2*x+y 0.5*c+2*x+2*y 0; - 2*c+x+2*y 2.5*c+y 0.5*c+x+2*y 0; - 2*c+2*y 2.5*c+2*x+y 0.5*c+2*y 0; - 2*c+2*y+z 2.5*c+2*x+y 0.5*c+2*y-z 0; - 2*c+y+z 2.5*c+2*x 0.5*c+y-z 0; - 2*c+z 2.5*c+2*x-y 0.5*c-z 0]; - -b1=[-1 -1 -1]/sqrt(3); -n1=[-1 0 1]/sqrt(2); - -links=[1 2 b1 n1; - 2 3 b1 n1; - 3 4 b1 n1; - 4 5 b1 n1; - 5 6 b1 n1; - 6 7 b1 n1; - 7 8 b1 n1; - 8 9 b1 n1; - 9 10 b1 n1; - 10 1 b1 n1]; - +c = 1 / amag; +x = 0.5 / (amag * sqrt(6)); +y = 0.5 / (amag * sqrt(3)); +z = 0.5 / (amag * sqrt(2)); + +rn = [2 * c 2.5 * c + 2 * x - y 0.5 * c 0; + 2 * c + x 2.5 * c - y 0.5 * c + x 0; + 2 * c + 2 * x 2.5 * c - 2 * x - y 0.5 * c + 2 * x 0; + 2 * c + 2 * x + y 2.5 * c - 2 * x 0.5 * c + 2 * x + y 0; + 2 * c + 2 * x + 2 * y 2.5 * c - 2 * x + y 0.5 * c + 2 * x + 2 * y 0; + 2 * c + x + 2 * y 2.5 * c + y 0.5 * c + x + 2 * y 0; + 2 * c + 2 * y 2.5 * c + 2 * x + y 0.5 * c + 2 * y 0; + 2 * c + 2 * y + z 2.5 * c + 2 * x + y 0.5 * c + 2 * y - z 0; + 2 * c + y + z 2.5 * c + 2 * x 0.5 * c + y - z 0; + 2 * c + z 2.5 * c + 2 * x - y 0.5 * c - z 0]; + +b1 = [-1 -1 -1] / sqrt(3); +n1 = [-1 0 1] / sqrt(2); + +links = [1 2 b1 n1; + 2 3 b1 n1; + 3 4 b1 n1; + 4 5 b1 n1; + 5 6 b1 n1; + 6 7 b1 n1; + 7 8 b1 n1; + 8 9 b1 n1; + 9 10 b1 n1; + 10 1 b1 n1]; %create mirror of prismatic loops (outside boundary) % rn_mirror = [rn(:,1)+dx , rn(:,2) , rn(:,3)+dx , zeros(length(rn(:,1)),1)+67]; % links_mirror = links; % links_mirror(:,1) = links(:,2) + max(max(links(:,1:2))); % links_mirror(:,2) = links(:,1) + max(max(links(:,1:2))); -% +% % rn = vertcat(rn,rn_mirror); % links = vertcat(links,links_mirror); %% %Edge and screw glide and climb mobility parameters -mobility='mobbcc1'; +mobility = 'mobbcc1'; global Bscrew Bedge Beclimb Bline %Bedge=1e-4; %Pa s %Bscrew=1e-5; %Pa s %Beclimb=1e5; %Pa s - really big %Bline=1e-4*min(Bscrew,Bedge); -Bedge=1; -Bscrew=10; -Beclimb=1e10; -Bline=1e-4*min(Bscrew,Bedge); +Bedge = 1; +Bscrew = 10; +Beclimb = 1e10; +Bline = 1e-4 * min(Bscrew, Bedge); %Meshing -maxconnections=4; -lmax =0.25/amag; -lmin = 0.1/amag; -areamin=lmin*lmin*sin(60/180*pi)*0.5; -areamax=20*areamin; -doremesh=1; %flat set to 0 or 1 that turns the remesh functions off or on -docollision=1; %flat set to 0 or 1 that turns collision detection off or on -doseparation=1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on -dovirtmesh=1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on +maxconnections = 4; +lmax = 0.25 / amag; +lmin = 0.1 / amag; +areamin = lmin * lmin * sin(60/180 * pi) * 0.5; +areamax = 20 * areamin; +doremesh = 1; %flat set to 0 or 1 that turns the remesh functions off or on +docollision = 1; %flat set to 0 or 1 that turns collision detection off or on +doseparation = 1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on +dovirtmesh = 1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on %Simulation time -dt0=1E5; +dt0 = 1E5; intSimTime = 0; sinTime = 0; %dtplot=2E-9; %2ns -dtplot=5E4; -doplot=1; % frame recording: 1 == on, 0 == off +dtplot = 5E4; +doplot = 1; % frame recording: 1 == on, 0 == off totalSimTime = 1E7; curstep = 0; simTime = 0; %Integrator -integrator='int_trapezoid'; +integrator = 'int_trapezoid'; %integrator='int_trapezoid_stoc'; %in development -a=lmin/sqrt(3)*0.5; -Ec = MU/(4*pi)*log(a/0.1); -rann = 0.5*a; -rntol = 0.5*rann; % need to do convergence studies on all these parameters +a = lmin / sqrt(3) * 0.5; +Ec = MU / (4 * pi) * log(a / 0.1); +rann = 0.5 * a; +rntol = 0.5 * rann; % need to do convergence studies on all these parameters rmax = lmax; %Plotting -plotfreq=5; -plim=12/amag; %12microns -viewangle=[-35,15]; -printfreq=1; -printnode=2; - +plotFreq = 5; +plim = 12 / amag; %12microns +viewangle = [-35, 15]; +printfreq = 1; +printnode = 2; diff --git a/input/inputsquareloopcrossslip2.m b/input/inputsquareloopcrossslip2.m index a6605b1b..f92401d4 100644 --- a/input/inputsquareloopcrossslip2.m +++ b/input/inputsquareloopcrossslip2.m @@ -23,128 +23,126 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clear all %% SOURCE GENERATION PARAMETERS -amag=3.18e-4; -mumag = 160E3; % MPa only used for plotting +amag = 3.18e-4; +mumag = 160E3; % MPa only used for plotting CRYSTAL_STRUCTURE = 'bcc'; NUM_SOURCES = 1; -DIST_SOURCE = 0.5/amag; +DIST_SOURCE = 0.5 / amag; %% FEM PARAMETERS %Cantilever -dx=30/amag; %10micron -dy=5/amag; %2micron -dz=5/amag; %2micron - -mx=20; % number of elements along beam length -loading=1; -vertices = [0,0,0;... - dx,0,0;... - 0,dy,0;... - dx,dy,0;... - 0,0,dz;... - dx,0,dz;... - 0,dy,dz;... - dx,dy,dz]; +dx = 30 / amag; %10micron +dy = 5 / amag; %2micron +dz = 5 / amag; %2micron + +mx = 20; % number of elements along beam length +loading = 1; +vertices = [0, 0, 0; ... + dx, 0, 0; ... + 0, dy, 0; ... + dx, dy, 0; ... + 0, 0, dz; ... + dx, 0, dz; ... + 0, dy, dz; ... + dx, dy, dz]; %% MATERIAL CONSTANTS %MU = 160E9; %160GPa MU = 1; -NU = 0.305; +NU = 0.305; %% DDLab PARAMETERS -c=1/amag; -x=0.5/(amag*sqrt(6)); -y=0.5/(amag*sqrt(3)); -z=0.5/(amag*sqrt(2)); - -rn=[ 2.5*c+x-z 2.5*c-y 0.5*c+x+z 0; - 2.5*c+2*x-z 2.5*c-2*x-y 0.5*c+2*x+z 0; - 2.5*c+2*x+y-z 2.5*c-2*x 0.5*c+2*x+y+z 0; - 2.5*c+2*x+y 2.5*c-2*x 0.5*c+2*x+y 0; - 2.5*c+2*x+2*y 2.5*c-2*x+y 0.5*c+2*x+2*y 0; - 2.5*c+x+2*y 2.5*c+y 0.5*c+x+2*y 0; - 2.5*c+2*y 2.5*c+2*x+y 0.5*c+2*y 0; - 2.5*c+y 2.5*c+2*x 0.5*c+y 0; - 2.5*c+y-z 2.5*c+2*x 0.5*c+y+z 0; - 2.5*c-z 2.5*c+2*x-y 0.5*c+z 0]; - -b1=[-1 -1 -1]/sqrt(3); -n1=[-1 0 1]/sqrt(2); - -links=[1 2 b1 n1; - 2 3 b1 n1; - 3 4 b1 n1; - 4 5 b1 n1; - 5 6 b1 n1; - 6 7 b1 n1; - 7 8 b1 n1; - 8 9 b1 n1; - 9 10 b1 n1; - 10 1 b1 n1]; - +c = 1 / amag; +x = 0.5 / (amag * sqrt(6)); +y = 0.5 / (amag * sqrt(3)); +z = 0.5 / (amag * sqrt(2)); + +rn = [2.5 * c + x - z 2.5 * c - y 0.5 * c + x + z 0; + 2.5 * c + 2 * x - z 2.5 * c - 2 * x - y 0.5 * c + 2 * x + z 0; + 2.5 * c + 2 * x + y - z 2.5 * c - 2 * x 0.5 * c + 2 * x + y + z 0; + 2.5 * c + 2 * x + y 2.5 * c - 2 * x 0.5 * c + 2 * x + y 0; + 2.5 * c + 2 * x + 2 * y 2.5 * c - 2 * x + y 0.5 * c + 2 * x + 2 * y 0; + 2.5 * c + x + 2 * y 2.5 * c + y 0.5 * c + x + 2 * y 0; + 2.5 * c + 2 * y 2.5 * c + 2 * x + y 0.5 * c + 2 * y 0; + 2.5 * c + y 2.5 * c + 2 * x 0.5 * c + y 0; + 2.5 * c + y - z 2.5 * c + 2 * x 0.5 * c + y + z 0; + 2.5 * c - z 2.5 * c + 2 * x - y 0.5 * c + z 0]; + +b1 = [-1 -1 -1] / sqrt(3); +n1 = [-1 0 1] / sqrt(2); + +links = [1 2 b1 n1; + 2 3 b1 n1; + 3 4 b1 n1; + 4 5 b1 n1; + 5 6 b1 n1; + 6 7 b1 n1; + 7 8 b1 n1; + 8 9 b1 n1; + 9 10 b1 n1; + 10 1 b1 n1]; %create mirror of prismatic loops (outside boundary) % rn_mirror = [rn(:,1)+dx , rn(:,2) , rn(:,3)+dx , zeros(length(rn(:,1)),1)+67]; % links_mirror = links; % links_mirror(:,1) = links(:,2) + max(max(links(:,1:2))); % links_mirror(:,2) = links(:,1) + max(max(links(:,1:2))); -% +% % rn = vertcat(rn,rn_mirror); % links = vertcat(links,links_mirror); %% %Edge and screw glide and climb mobility parameters -mobility='mobbcc1'; +mobility = 'mobbcc1'; global Bscrew Bedge Beclimb Bline %Bedge=1e-4; %Pa s %Bscrew=1e-5; %Pa s %Beclimb=1e5; %Pa s - really big %Bline=1e-4*min(Bscrew,Bedge); -Bedge=1; -Bscrew=10; -Beclimb=1e10; -Bline=1e-4*min(Bscrew,Bedge); +Bedge = 1; +Bscrew = 10; +Beclimb = 1e10; +Bline = 1e-4 * min(Bscrew, Bedge); %Meshing -maxconnections=4; -lmax =0.25/amag; -lmin = 0.1/amag; -areamin=lmin*lmin*sin(60/180*pi)*0.5; -areamax=20*areamin; -doremesh=1; %flat set to 0 or 1 that turns the remesh functions off or on -docollision=1; %flat set to 0 or 1 that turns collision detection off or on -doseparation=1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on -dovirtmesh=1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on +maxconnections = 4; +lmax = 0.25 / amag; +lmin = 0.1 / amag; +areamin = lmin * lmin * sin(60/180 * pi) * 0.5; +areamax = 20 * areamin; +doremesh = 1; %flat set to 0 or 1 that turns the remesh functions off or on +docollision = 1; %flat set to 0 or 1 that turns collision detection off or on +doseparation = 1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on +dovirtmesh = 1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on %Simulation time -dt0=1E5; +dt0 = 1E5; intSimTime = 0; sinTime = 0; %dtplot=2E-9; %2ns -dtplot=5E4; -doplot=1; % frame recording: 1 == on, 0 == off +dtplot = 5E4; +doplot = 1; % frame recording: 1 == on, 0 == off totalSimTime = 1E7; curstep = 0; simTime = 0; %Integrator -integrator='int_trapezoid'; +integrator = 'int_trapezoid'; %integrator='int_trapezoid_stoc'; %in development -a=lmin/sqrt(3)*0.5; -Ec = MU/(4*pi)*log(a/0.1); -rann = 0.5*a; -rntol = 0.5*rann; % need to do convergence studies on all these parameters +a = lmin / sqrt(3) * 0.5; +Ec = MU / (4 * pi) * log(a / 0.1); +rann = 0.5 * a; +rntol = 0.5 * rann; % need to do convergence studies on all these parameters rmax = lmax; %Plotting -plotfreq=5; -plim=12/amag; %12microns -viewangle=[-35,15]; -printfreq=1; -printnode=2; - +plotFreq = 5; +plim = 12 / amag; %12microns +viewangle = [-35, 15]; +printfreq = 1; +printnode = 2; diff --git a/input/inputsquareloopprismatic.m b/input/inputsquareloopprismatic.m index f20c2bf7..63cbfce0 100644 --- a/input/inputsquareloopprismatic.m +++ b/input/inputsquareloopprismatic.m @@ -23,30 +23,30 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clear all %% SOURCE GENERATION PARAMETERS -amag=3.18e-4; +amag = 3.18e-4; mumag = 135E3; % MPa only used for plotting CRYSTAL_STRUCTURE = 'bcc'; NUM_SOURCES = 1; -DIST_SOURCE = 0.5/amag; +DIST_SOURCE = 0.5 / amag; %% FEM PARAMETERS %Cantilever -dx=19.5/amag; %10micron -dy=5.4/amag; %2micron -dz=5.3/amag; %2micron - -mx=40; % number of elements along beam length -loading=1; -vertices = [0,0,0;... - dx,0,0;... - 0,dy,0;... - dx,dy,0;... - 0,0,dz;... - dx,0,dz;... - 0,dy,dz;... - dx,dy,dz]; +dx = 19.5 / amag; %10micron +dy = 5.4 / amag; %2micron +dz = 5.3 / amag; %2micron + +mx = 40; % number of elements along beam length +loading = 1; +vertices = [0, 0, 0; ... + dx, 0, 0; ... + 0, dy, 0; ... + dx, dy, 0; ... + 0, 0, dz; ... + dx, 0, dz; ... + 0, dy, dz; ... + dx, dy, dz]; %% MATERIAL CONSTANTS @@ -56,32 +56,31 @@ %% DDLab PARAMETERS -c=1/amag; -x=0.5/(amag*sqrt(2)); -y=0.5/(amag*sqrt(6)); - -rn=[ 2*c 2.5*c+2*y 1.5*c 7; - 2*c+x 2.5*c+2*y 1.5*c-x 0; - 2*c+2*x 2.5*c+2*y 1.5*c-2*x 7; - 2*c+2*x+y 2.5*c 1.5*c-2*x+y 0; - 2*c+2*x+2*y 2.5*c-2*y 1.5*c-2*x+2*y 7; - 2*c+x+2*y 2.5*c-2*y 1.5*c-x+2*y 0; - 2*c+2*y 2.5*c-2*y 1.5*c+2*y 7; - 2*c+y 2.5*c 1.5*c+y 0]; - -b1=[1 1 1]/sqrt(3); -n1=[-1 0 1]/sqrt(2); -n2=[1 -2 1]/sqrt(6); - -links=[1 2 b1 n1; - 2 3 b1 n1; - 3 4 b1 n1; - 4 5 b1 n1; - 5 6 b1 n1; - 6 7 b1 n1; - 7 8 b1 n1; - 8 1 b1 n1]; - +c = 1 / amag; +x = 0.5 / (amag * sqrt(2)); +y = 0.5 / (amag * sqrt(6)); + +rn = [2 * c 2.5 * c + 2 * y 1.5 * c 7; + 2 * c + x 2.5 * c + 2 * y 1.5 * c - x 0; + 2 * c + 2 * x 2.5 * c + 2 * y 1.5 * c - 2 * x 7; + 2 * c + 2 * x + y 2.5 * c 1.5 * c - 2 * x + y 0; + 2 * c + 2 * x + 2 * y 2.5 * c - 2 * y 1.5 * c - 2 * x + 2 * y 7; + 2 * c + x + 2 * y 2.5 * c - 2 * y 1.5 * c - x + 2 * y 0; + 2 * c + 2 * y 2.5 * c - 2 * y 1.5 * c + 2 * y 7; + 2 * c + y 2.5 * c 1.5 * c + y 0]; + +b1 = [1 1 1] / sqrt(3); +n1 = [-1 0 1] / sqrt(2); +n2 = [1 -2 1] / sqrt(6); + +links = [1 2 b1 n1; + 2 3 b1 n1; + 3 4 b1 n1; + 4 5 b1 n1; + 5 6 b1 n1; + 6 7 b1 n1; + 7 8 b1 n1; + 8 1 b1 n1]; %create mirror of prismatic loops (outside boundary) % rn_mirror = [rn(:,1)+dx , rn(:,2) , rn(:,3)+dx , zeros(length(rn(:,1)),1)+67]; @@ -94,52 +93,52 @@ %% %Edge and screw glide and climb mobility parameters -mobility='mobbcc_bb'; +mobility = 'mobbcc_bb'; global Bscrew Bedge Beclimb Bline %Bedge=1e-4; %Pa s %Bscrew=1e-5; %Pa s %Beclimb=1e5; %Pa s - really big %Bline=1e-4*min(Bscrew,Bedge); -Bedge=1; -Bscrew=100; -Beclimb=1e5; -Bline=20e-4*min(Bscrew,Bedge); +Bedge = 1; +Bscrew = 100; +Beclimb = 1e5; +Bline = 20e-4 * min(Bscrew, Bedge); %Meshing -maxconnections=4; -lmax =0.25/amag; -lmin = 0.1/amag; -areamin=lmin*lmin*sin(60/180*pi)*0.5; -areamax=20*areamin; -doremesh=1; %flat set to 0 or 1 that turns the remesh functions off or on -docollision=1; %flat set to 0 or 1 that turns collision detection off or on -doseparation=1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on -dovirtmesh=1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on +maxconnections = 4; +lmax = 0.25 / amag; +lmin = 0.1 / amag; +areamin = lmin * lmin * sin(60/180 * pi) * 0.5; +areamax = 20 * areamin; +doremesh = 1; %flat set to 0 or 1 that turns the remesh functions off or on +docollision = 1; %flat set to 0 or 1 that turns collision detection off or on +doseparation = 1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on +dovirtmesh = 1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on %Simulation time -dt0=2.048e9; +dt0 = 2.048e9; intSimTime = 0; %sinTime = 0; %dtplot=2E-9; %2ns -dtplot=5E4; -doplot=1; % frame recording: 1 == on, 0 == off +dtplot = 5E4; +doplot = 1; % frame recording: 1 == on, 0 == off totalSimTime = 3.3608e12; curstep = 0; simTime = 0; %Integrator -integrator='int_trapezoid_bb_old'; +integrator = 'int_trapezoid_bb_old'; %integrator='int_trapezoid_stoc'; %in development -a=(lmin/sqrt(3)*0.5)/4; -Ec = MU/(4*pi)*log(a/0.1); -rann = 2*a; -rntol = 0.5*rann*100; % need to do convergence studies on all these parameters -rmax = 0.5*lmin; +a = (lmin / sqrt(3) * 0.5) / 4; +Ec = MU / (4 * pi) * log(a / 0.1); +rann = 2 * a; +rntol = 0.5 * rann * 100; % need to do convergence studies on all these parameters +rmax = 0.5 * lmin; %Plotting -plotfreq=10; -plim=12/amag; %12microns -viewangle=[-35,15]; -printfreq=500; -printnode=2; +plotFreq = 10; +plim = 12 / amag; %12microns +viewangle = [-35, 15]; +printfreq = 500; +printnode = 2; diff --git a/input/inputsquareloopswitch.m b/input/inputsquareloopswitch.m index fd61ae82..b1e60762 100644 --- a/input/inputsquareloopswitch.m +++ b/input/inputsquareloopswitch.m @@ -23,125 +23,123 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clear all %% SOURCE GENERATION PARAMETERS -amag=3.18e-4; -mumag = 160E3; % MPa only used for plotting +amag = 3.18e-4; +mumag = 160E3; % MPa only used for plotting CRYSTAL_STRUCTURE = 'bcc'; NUM_SOURCES = 1; -DIST_SOURCE = 0.5/amag; +DIST_SOURCE = 0.5 / amag; %% FEM PARAMETERS %Cantilever -dx=30/amag; %10micron -dy=5/amag; %2micron -dz=5/amag; %2micron - -mx=40; % number of elements along beam length -loading=1; -vertices = [0,0,0;... - dx,0,0;... - 0,dy,0;... - dx,dy,0;... - 0,0,dz;... - dx,0,dz;... - 0,dy,dz;... - dx,dy,dz]; +dx = 30 / amag; %10micron +dy = 5 / amag; %2micron +dz = 5 / amag; %2micron + +mx = 40; % number of elements along beam length +loading = 1; +vertices = [0, 0, 0; ... + dx, 0, 0; ... + 0, dy, 0; ... + dx, dy, 0; ... + 0, 0, dz; ... + dx, 0, dz; ... + 0, dy, dz; ... + dx, dy, dz]; %% MATERIAL CONSTANTS %MU = 160E9; %160GPa MU = 1; -NU = 0.305; +NU = 0.305; %% DDLab PARAMETERS -c=1/amag; -x=0.5/(amag*sqrt(6)); -y=0.5/(amag*sqrt(3)); - -rn=[ 8*c 2.5*c+2*x-y 0.5*c 0; - 8*c-x 2.5*c-y 0.5*c+x 0; - 8*c-2*x 2.5*c-2*x-y 0.5*c+2*x 0; - 8*c-2*x-y 2.5*c-2*x 0.5*c+2*x+y 0; - 8*c-2*x-2*y 2.5*c-2*x+y 0.5*c+2*x+2*y 0; - 8*c-x-2*y 2.5*c+y 0.5*c+x+2*y 0; - 8*c-2*y 2.5*c+2*x+y 0.5*c+2*y 0; - 8*c-y 2.5*c+2*x 0.5*c+y 0]; - -b1=[-1 -1 -1]/sqrt(3); -b2=[-1 1 1]/sqrt(3); -n1=[-1 0 1]/sqrt(2); -n2=[1 0 1]/sqrt(2); - -links=[ 1 2 b2 n2; - 2 3 b2 n2; - 3 4 b2 n2; - 4 5 b2 n2; - 5 6 b2 n2; - 6 7 b2 n2; - 7 8 b2 n2; - 8 1 b2 n2]; - +c = 1 / amag; +x = 0.5 / (amag * sqrt(6)); +y = 0.5 / (amag * sqrt(3)); + +rn = [8 * c 2.5 * c + 2 * x - y 0.5 * c 0; + 8 * c - x 2.5 * c - y 0.5 * c + x 0; + 8 * c - 2 * x 2.5 * c - 2 * x - y 0.5 * c + 2 * x 0; + 8 * c - 2 * x - y 2.5 * c - 2 * x 0.5 * c + 2 * x + y 0; + 8 * c - 2 * x - 2 * y 2.5 * c - 2 * x + y 0.5 * c + 2 * x + 2 * y 0; + 8 * c - x - 2 * y 2.5 * c + y 0.5 * c + x + 2 * y 0; + 8 * c - 2 * y 2.5 * c + 2 * x + y 0.5 * c + 2 * y 0; + 8 * c - y 2.5 * c + 2 * x 0.5 * c + y 0]; + +b1 = [-1 -1 -1] / sqrt(3); +b2 = [-1 1 1] / sqrt(3); +n1 = [-1 0 1] / sqrt(2); +n2 = [1 0 1] / sqrt(2); + +links = [1 2 b2 n2; + 2 3 b2 n2; + 3 4 b2 n2; + 4 5 b2 n2; + 5 6 b2 n2; + 6 7 b2 n2; + 7 8 b2 n2; + 8 1 b2 n2]; %create mirror of prismatic loops (outside boundary) % rn_mirror = [rn(:,1)+dx , rn(:,2) , rn(:,3)+dx , zeros(length(rn(:,1)),1)+67]; % links_mirror = links; % links_mirror(:,1) = links(:,2) + max(max(links(:,1:2))); % links_mirror(:,2) = links(:,1) + max(max(links(:,1:2))); -% +% % rn = vertcat(rn,rn_mirror); % links = vertcat(links,links_mirror); %% %Edge and screw glide and climb mobility parameters -mobility='mobbcc1'; +mobility = 'mobbcc1'; global Bscrew Bedge Beclimb Bline %Bedge=1e-4; %Pa s %Bscrew=1e-5; %Pa s %Beclimb=1e5; %Pa s - really big %Bline=1e-4*min(Bscrew,Bedge); -Bedge=1; -Bscrew=10; -Beclimb=1e10; -Bline=1e-4*min(Bscrew,Bedge); +Bedge = 1; +Bscrew = 10; +Beclimb = 1e10; +Bline = 1e-4 * min(Bscrew, Bedge); %Meshing -maxconnections=4; -lmax =0.25/amag; -lmin = 0.1/amag; -areamin=lmin*lmin*sin(60/180*pi)*0.5; -areamax=20*areamin; -doremesh=1; %flat set to 0 or 1 that turns the remesh functions off or on -docollision=1; %flat set to 0 or 1 that turns collision detection off or on -doseparation=1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on -dovirtmesh=1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on +maxconnections = 4; +lmax = 0.25 / amag; +lmin = 0.1 / amag; +areamin = lmin * lmin * sin(60/180 * pi) * 0.5; +areamax = 20 * areamin; +doremesh = 1; %flat set to 0 or 1 that turns the remesh functions off or on +docollision = 1; %flat set to 0 or 1 that turns collision detection off or on +doseparation = 1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on +dovirtmesh = 1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on %Simulation time -dt0=1E5; +dt0 = 1E5; intSimTime = 0; sinTime = 0; %dtplot=2E-9; %2ns -dtplot=5E4; -doplot=1; % frame recording: 1 == on, 0 == off +dtplot = 5E4; +doplot = 1; % frame recording: 1 == on, 0 == off totalSimTime = 1E7; curstep = 0; simTime = 0; %Integrator -integrator='int_trapezoid'; +integrator = 'int_trapezoid'; %integrator='int_trapezoid_stoc'; %in development -a=lmin/sqrt(3)*0.5; -Ec = MU/(4*pi)*log(a/0.1); -rann = 0.5*a; -rntol = 0.5*rann; % need to do convergence studies on all these parameters +a = lmin / sqrt(3) * 0.5; +Ec = MU / (4 * pi) * log(a / 0.1); +rann = 0.5 * a; +rntol = 0.5 * rann; % need to do convergence studies on all these parameters rmax = lmax; %Plotting -plotfreq=5; -plim=12/amag; %12microns -viewangle=[-35,15]; -printfreq=1; -printnode=2; - +plotFreq = 5; +plim = 12 / amag; %12microns +viewangle = [-35, 15]; +printfreq = 1; +printnode = 2; diff --git a/input/inputtungsten.m b/input/inputtungsten.m index ecfae712..3931f546 100644 --- a/input/inputtungsten.m +++ b/input/inputtungsten.m @@ -23,30 +23,30 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clear all %% SOURCE GENERATION PARAMETERS -amag=3.18e-4; +amag = 3.18e-4; mumag = 145E3; % MPa only used for plotting CRYSTAL_STRUCTURE = 'bcc'; NUM_SOURCES = 4; -DIST_SOURCE = 0.1/amag; +DIST_SOURCE = 0.1 / amag; %% FEM PARAMETERS %Cantilever -dx=19.5/amag; %10micron -dy=5.4/amag; %2micron -dz=5.3/amag; %2micron - -mx=40; % number of elements along beam length -loading=1; -vertices = [0,0,0;... - dx,0,0;... - 0,dy,0;... - dx,dy,0;... - 0,0,dz;... - dx,0,dz;... - 0,dy,dz;... - dx,dy,dz]; +dx = 19.5 / amag; %10micron +dy = 5.4 / amag; %2micron +dz = 5.3 / amag; %2micron + +mx = 40; % number of elements along beam length +loading = 1; +vertices = [0, 0, 0; ... + dx, 0, 0; ... + 0, dy, 0; ... + dx, dy, 0; ... + 0, 0, dz; ... + dx, 0, dz; ... + 0, dy, dz; ... + dx, dy, dz]; %% MATERIAL CONSTANTS @@ -82,7 +82,7 @@ % 7 8 b1 n1; % 8 1 b1 n1]; - [rn,links] = bccsourcegen(NUM_SOURCES,DIST_SOURCE,dx,dy,dz); +[rn, links] = bccsourcegen(NUM_SOURCES, DIST_SOURCE, dx, dy, dz); % [rn]=[dx-0.5*dx,dy-0.5*dy,dz-0.5*dz,7; % dx-0.5*dx,dy-0.5*dy,dz-0.55*dz,7; % dx-0.49*dx,dy-0.5*dy,dz-0.55*dz,7]; @@ -101,56 +101,56 @@ %% %Edge and screw glide and climb mobility parameters -mobility='mobbcc1'; +mobility = 'mobbcc1'; global Bscrew Bedge Beclimb Bline %Bedge=1e-4; %Pa s %Bscrew=1e-5; %Pa s %Beclimb=1e5; %Pa s - really big %Bline=1e-4*min(Bscrew,Bedge); -Bedge=1; -Bscrew=2; -Beclimb=1e10; -Bline=1e-4*min(Bscrew,Bedge); +Bedge = 1; +Bscrew = 2; +Beclimb = 1e10; +Bline = 1e-4 * min(Bscrew, Bedge); %Meshing -maxconnections=4; -lmax =0.25/amag; -lmin = 0.05/amag; -areamin=lmin*lmin*sin(60/180*pi)*0.5; -areamax=20*areamin; -doremesh=1; %flat set to 0 or 1 that turns the remesh functions off or on -docollision=1; %flat set to 0 or 1 that turns collision detection off or on -doseparation=1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on -dovirtmesh=1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on +maxconnections = 4; +lmax = 0.25 / amag; +lmin = 0.05 / amag; +areamin = lmin * lmin * sin(60/180 * pi) * 0.5; +areamax = 20 * areamin; +doremesh = 1; %flat set to 0 or 1 that turns the remesh functions off or on +docollision = 1; %flat set to 0 or 1 that turns collision detection off or on +doseparation = 1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on +dovirtmesh = 1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on %Simulation time -dt0=1E6; +dt0 = 1E6; intSimTime = 0; sinTime = 0; %dtplot=2E-9; %2ns -dtplot=5E4; -doplot=1; % frame recording: 1 == on, 0 == off -totalSimTime = (2/amag)/(100*1E3*dx*(1E-4/160E9)); +dtplot = 5E4; +doplot = 1; % frame recording: 1 == on, 0 == off +totalSimTime = (2 / amag) / (100 * 1E3 * dx * (1E-4/160E9)); curstep = 0; simTime = 0; %Integrator -integrator='int_trapezoid'; +integrator = 'int_trapezoid'; %integrator='int_trapezoid_stoc'; %in development -a=(lmin/sqrt(3)*0.5)/4; -Ec = MU/(4*pi)*log(a/0.1); -rann = 2*a; -rntol = 0.5*rann*100; % need to do convergence studies on all these parameters +a = (lmin / sqrt(3) * 0.5) / 4; +Ec = MU / (4 * pi) * log(a / 0.1); +rann = 2 * a; +rntol = 0.5 * rann * 100; % need to do convergence studies on all these parameters rmax = lmax; %Plotting -plotfreq=10E7; -plim=12/amag; %12microns -viewangle=[-35,15]; -printfreq=500; -printnode=2; +plotFreq = 10E7; +plim = 12 / amag; %12microns +viewangle = [-35, 15]; +printfreq = 500; +printnode = 2; %GPU Setup -n_threads=512; +n_threads = 512; diff --git a/input/inputtungsten2.m b/input/inputtungsten2.m index 50aabfbc..236d9eda 100644 --- a/input/inputtungsten2.m +++ b/input/inputtungsten2.m @@ -23,43 +23,43 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clear all %% SOURCE GENERATION PARAMETERS -amag=3.18e-4; -mumag = 135E3; % MPa only used for plotting +amag = 3.18e-4; +mumag = 135E3; % MPa only used for plotting CRYSTAL_STRUCTURE = 'bcc'; NUM_SOURCES = 4; -DIST_SOURCE = 0.1/amag; +DIST_SOURCE = 0.1 / amag; %% FEM PARAMETERS %Cantilever -dx=19.5/amag; %10micron -dy=5.4/amag; %2micron -dz=5.3/amag; %2micron - -mx=40; % number of elements along beam length -loading=1; -vertices = [0,0,0;... - dx,0,0;... - 0,dy,0;... - dx,dy,0;... - 0,0,dz;... - dx,0,dz;... - 0,dy,dz;... - dx,dy,dz]; +dx = 19.5 / amag; %10micron +dy = 5.4 / amag; %2micron +dz = 5.3 / amag; %2micron + +mx = 40; % number of elements along beam length +loading = 1; +vertices = [0, 0, 0; ... + dx, 0, 0; ... + 0, dy, 0; ... + dx, dy, 0; ... + 0, 0, dz; ... + dx, 0, dz; ... + 0, dy, dz; ... + dx, dy, dz]; %% MATERIAL CONSTANTS %MU = 160E9; %160GPa MU = 1; -NU = 0.28; +NU = 0.28; %% DDLab PARAMETERS % c=1/amag; % x=0.25/(amag*sqrt(6)); % y=0.25/(amag*sqrt(3)); -% +% % rn=[ 3.7*c 2.7*c+2*x-y 0.25*c 0; % 3.7*c+x 2.7*c-y 0.25*c+x 0; % 3.7*c+2*x 2.7*c-2*x-y 0.25*c+2*x 0; @@ -68,21 +68,21 @@ % 3.7*c+x+2*y 2.7*c+y 0.25*c+x+2*y 0; % 3.7*c+2*y 2.7*c+2*x+y 0.25*c+2*y 0; % 3.7*c+y 2.7*c+2*x 0.25*c+y 0]; -% +% % b1=[-1 -1 -1]/sqrt(3); % n1=[-1 0 1]/sqrt(2); % n2=[1 0 -1]/sqrt(2); -% +% % links=[1 2 b1 n1; % 2 3 b1 n1; -% 3 4 b1 n1; +% 3 4 b1 n1; % 4 5 b1 n1; % 5 6 b1 n1; % 6 7 b1 n1; % 7 8 b1 n1; % 8 1 b1 n1]; - - [rn,links] = bccsurfsourcegen(NUM_SOURCES,DIST_SOURCE,dx,dy,dz); + +[rn, links] = bccsurfsourcegen(NUM_SOURCES, DIST_SOURCE, dx, dy, dz); % [rn]=[dx-0.5*dx,dy-0.5*dy,dz-0.5*dz,7; % dx-0.5*dx,dy-0.5*dy,dz-0.55*dz,7; % dx-0.49*dx,dy-0.5*dy,dz-0.55*dz,7]; @@ -95,63 +95,62 @@ % links_mirror = links; % links_mirror(:,1) = links(:,2) + max(max(links(:,1:2))); % links_mirror(:,2) = links(:,1) + max(max(links(:,1:2))); -% +% % rn = vertcat(rn,rn_mirror); % links = vertcat(links,links_mirror); %% %Edge and screw glide and climb mobility parameters -mobility='mobbcc_bb'; +mobility = 'mobbcc_bb'; global Bscrew Bedge Beclimb Bline %Bedge=1e-4; %Pa s %Bscrew=1e-5; %Pa s %Beclimb=1e5; %Pa s - really big %Bline=1e-4*min(Bscrew,Bedge); -Bedge=20; -Bscrew=100; -Beclimb=1e12; -Bline=1e-4*min(Bscrew,Bedge); +Bedge = 20; +Bscrew = 100; +Beclimb = 1e12; +Bline = 1e-4 * min(Bscrew, Bedge); %Meshing -maxconnections=4; -lmax =0.25/amag; -lmin = 0.05/amag; -areamin=lmin*lmin*sin(60/180*pi)*0.5; -areamax=20*areamin; -doremesh=1; %flat set to 0 or 1 that turns the remesh functions off or on -docollision=1; %flat set to 0 or 1 that turns collision detection off or on -doseparation=1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on -dovirtmesh=1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on +maxconnections = 4; +lmax = 0.25 / amag; +lmin = 0.05 / amag; +areamin = lmin * lmin * sin(60/180 * pi) * 0.5; +areamax = 20 * areamin; +doremesh = 1; %flat set to 0 or 1 that turns the remesh functions off or on +docollision = 1; %flat set to 0 or 1 that turns collision detection off or on +doseparation = 1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on +dovirtmesh = 1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on %Simulation time -dt0=1E6; +dt0 = 1E6; intSimTime = 0; sinTime = 0; %dtplot=2E-9; %2ns -dtplot=5E4; -doplot=1; % frame recording: 1 == on, 0 == off -totalSimTime = (2/amag)/(100*1E3*dx*(1E-4/160E9)); +dtplot = 5E4; +doplot = 1; % frame recording: 1 == on, 0 == off +totalSimTime = (2 / amag) / (100 * 1E3 * dx * (1E-4/160E9)); curstep = 0; simTime = 0; %Integrator -integrator='int_trapezoid'; +integrator = 'int_trapezoid'; %integrator='int_trapezoid_stoc'; %in development -a=lmin/sqrt(3)*0.5; -Ec = MU/(4*pi)*log(a/0.1); -rann = 0.5*a; -rntol = 50*rann; % need to do convergence studies on all these parameters +a = lmin / sqrt(3) * 0.5; +Ec = MU / (4 * pi) * log(a / 0.1); +rann = 0.5 * a; +rntol = 50 * rann; % need to do convergence studies on all these parameters rmax = lmax; %Plotting -plotfreq=10E7; -plim=12/amag; %12microns -viewangle=[-35,15]; -printfreq=500; -printnode=2; +plotFreq = 10E7; +plim = 12 / amag; %12microns +viewangle = [-35, 15]; +printfreq = 500; +printnode = 2; %GPU Setup -n_threads=512; - +n_threads = 512; diff --git a/input/junctiondisplacement.m b/input/junctiondisplacement.m index fa57c66a..1401a7d0 100644 --- a/input/junctiondisplacement.m +++ b/input/junctiondisplacement.m @@ -3,7 +3,7 @@ global Bscrew Bedge Beclimb Bline l = 250; -b = 0.5*[1 1 1]; +b = 0.5 * [1 1 1]; side1 = [1 -2 1]; side2 = [2 -1 -1]; @@ -12,205 +12,208 @@ side5 = [-2 1 1]; side6 = [-1 -1 2]; -n1 = cross(side1,b); -n2 = cross(side2,b); -n3 = cross(side3,b); -n4 = cross(side4,b); -n5 = cross(side5,b); -n6 = cross(side6,b); +n1 = cross(side1, b); +n2 = cross(side2, b); +n3 = cross(side3, b); +n4 = cross(side4, b); +n5 = cross(side5, b); +n6 = cross(side6, b); %start from center of grid % Loop 1 A1 = [2500 2500 900]; -A2 = A1 + l*side1; -A3 = A2 + l*side2; -A4 = A3 + l*side3; -A5 = A4 + l*side4; -A6 = A5 + l*side5; -A7 = A6 + l*side6; %should equal P1, consistency check +A2 = A1 + l * side1; +A3 = A2 + l * side2; +A4 = A3 + l * side3; +A5 = A4 + l * side4; +A6 = A5 + l * side5; +A7 = A6 + l * side6; %should equal P1, consistency check % Loop 2 -B1 = A1 - (side1+side2)*l; -B2 = B1 + l*side1; -B3 = B2 + l*side2; -B4 = B3 + l*side3; -B5 = B4 + l*side4; -B6 = B5 + l*side5; -B7 = B6 + l*side6; %should equal P1, consistency check - -rn = [ - A1, 0; - A2, 0; - A3, 0; - A4, 0; - A5, 0; - A6, 0; - - B1, 0; - B2, 0; - B3, 0; - B4, 0; - B5, 0; - B6, 0; - ]; - -links = [ 1 2 b n1; - 2 3 b n2; - 3 4 b n3; - 4 5 b n4; - 5 6 b n5; - 6 1 b n6; - - 7 8 b n1; - 8 9 b n2; - 9 10 b n3; - 10 11 b n4; - 11 12 b n5; - 12 7 b n6; - ]; - -MU = 1; -NU = 0.305; -maxconnections=8; -lmax = 1000; -lmin = 100; -areamin=lmin*lmin*sin(60/180*pi)*0.5; -areamax=20*areamin; -a=lmin/sqrt(3)*0.5; -Ec = MU/(4*pi)*log(a/0.1); -dt0=1; -mobility='mobbcc0'; +B1 = A1 - (side1 + side2) * l; +B2 = B1 + l * side1; +B3 = B2 + l * side2; +B4 = B3 + l * side3; +B5 = B4 + l * side4; +B6 = B5 + l * side5; +B7 = B6 + l * side6; %should equal P1, consistency check + +rn = [ + A1, 0; + A2, 0; + A3, 0; + A4, 0; + A5, 0; + A6, 0; + + B1, 0; + B2, 0; + B3, 0; + B4, 0; + B5, 0; + B6, 0; + ]; + +links = [1 2 b n1; + 2 3 b n2; + 3 4 b n3; + 4 5 b n4; + 5 6 b n5; + 6 1 b n6; + + 7 8 b n1; + 8 9 b n2; + 9 10 b n3; + 10 11 b n4; + 11 12 b n5; + 12 7 b n6; + ]; + +MU = 1; +NU = 0.305; +maxconnections = 8; +lmax = 1000; +lmin = 100; +areamin = lmin * lmin * sin(60/180 * pi) * 0.5; +areamax = 20 * areamin; +a = lmin / sqrt(3) * 0.5; +Ec = MU / (4 * pi) * log(a / 0.1); +dt0 = 1; +mobility = 'mobbcc0'; intSimTime = 0; sinTime = 0; -dtplot=3e6;% 3 ms (code in units of ns) -doplot=1;% frame recording: 1 == on, 0 == off +dtplot = 3e6; % 3 ms (code in units of ns) +doplot = 1; % frame recording: 1 == on, 0 == off totalSimTime = 0.3e12; curstep = 0; simTime = 0; -Bscrew=1e0; -Bedge=1e0; -Beclimb=1e10; -Bline=1.0e-4*min(Bscrew,Bedge); +Bscrew = 1e0; +Bedge = 1e0; +Beclimb = 1e10; +Bline = 1.0e-4 * min(Bscrew, Bedge); global USING_GPU; -USING_GPU=0; %0 if CPU only. - -integrator='int_trapezoid'; -rann = 0.5*a; -rntol = 0.5*rann; -doremesh=1; %flat set to 0 or 1 that turns the remesh functions off or on -docollision=1; %flat set to 0 or 1 that turns collision detection off or on -doseparation=1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on -dovirtmesh=1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on -plotfreq=1; -plim=7000; -appliedstress =10^-2*[2 0 1; 0 2 -1; 1 -1 0]; -viewangle=[90 0 ]; -printfreq=1; -printnode=3; -rmax=100; %maximum distance a node may travel in one cycle +USING_GPU = 0; %0 if CPU only. + +integrator = 'int_trapezoid'; +rann = 0.5 * a; +rntol = 0.5 * rann; +doremesh = 1; %flat set to 0 or 1 that turns the remesh functions off or on +docollision = 1; %flat set to 0 or 1 that turns collision detection off or on +doseparation = 1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on +dovirtmesh = 1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on +plotFreq = 1; +plim = 7000; +appliedstress = 10^ - 2 * [2 0 1; 0 2 -1; 1 -1 0]; +viewangle = [90 0]; +printfreq = 1; +printnode = 3; +rmax = 100; %maximum distance a node may travel in one cycle %FEM CANTILEVER PARAMETERS a_mag = 3.18e-4; -dx=8; %microns -dy=2; %microns -dz=2; %microns +dx = 8; %microns +dy = 2; %microns +dz = 2; %microns %tungsten "a" is 0.000274 -dx = dx/a_mag; -dy = dy/a_mag; -dz = dz/a_mag; -DIST_SOURCE = 0.5/a_mag; - -mx=20; -loading=1; -vertices = [0,0,0;... - dx,0,0;... - 0,dy,0;... - dx,dy,0;... - 0,0,dz;... - dx,0,dz;... - 0,dy,dz;... - dx,dy,dz]; - -if(~exist('dt','var')) - dt=dt0; +dx = dx / a_mag; +dy = dy / a_mag; +dz = dz / a_mag; +DIST_SOURCE = 0.5 / a_mag; + +mx = 20; +loading = 1; +vertices = [0, 0, 0; ... + dx, 0, 0; ... + 0, dy, 0; ... + dx, dy, 0; ... + 0, 0, dz; ... + dx, 0, dz; ... + 0, dy, dz; ... + dx, dy, dz]; + +if (~exist('dt', 'var')) + dt = dt0; end -dt=min(dt,dt0); -disp('Initiliazing connectivity list. Please wait.'); -[connectivity,linksinconnect]=genconnectivity(rn,links,maxconnections); +dt = min(dt, dt0); -disp('Constructing stiffness matrix K and precomputing L,U decompositions. Please wait.'); -[B,xnodes,mno,nc,n,D,kg,K,L,U,Sleft,Sright,Stop,Sbot,... - Sfront,Sback,gammat,gammau,gammaMixed,fixedDofs,freeDofs,... - w,h,d,my,mz,mel] = finiteElement3D(dx,dy,dz,mx,MU,NU,loading); +disp('Initiliazing connectivity list. Please wait.'); +[connectivity, linksinconnect] = genconnectivity(rn, links, maxconnections); -disp('Creating surface mesh. Please wait.'); -[TriangleCentroids,TriangleNormals,tri,Xb] = ... - MeshSurfaceTriangulation(xnodes,Stop,Sbot,Sfront,Sback,Sleft,Sright); +disp('Constructing stiffness matrix K and precomputing L,U decompositions. Please wait.'); +[B, xnodes, mno, nc, n, D, kg, K, L, U, Sleft, Sright, Stop, Sbot, ... + Sfront, Sback, gammat, gammau, gammaMixed, fixedDofs, freeDofs, ... + w, h, d, my, mz, mel] = finiteElement3D(dx, dy, dz, mx, MU, NU, loading); -disp('Calculating displacements from segments. Please wait.'); -[uhat,~,~] = FEMcoupler(rn,links,maxconnections,a,MU,NU,xnodes,mno,kg,L,U,... - gammau,gammat,gammaMixed,fixedDofs,freeDofs,dx,simTime); +disp('Creating surface mesh. Please wait.'); +[TriangleCentroids, TriangleNormals, tri, Xb] = ... + MeshSurfaceTriangulation(xnodes, Stop, Sbot, Sfront, Sback, Sleft, Sright); + +disp('Calculating displacements from segments. Please wait.'); +[uhat, ~, ~] = FEMcoupler(rn, links, maxconnections, a, MU, NU, xnodes, mno, kg, L, U, ... + gammau, gammat, gammaMixed, fixedDofs, freeDofs, dx, simTime); %fprintf('fend = %d, Ubar = %d, simTime = %d \n',fend,Ubar,simTime); disp('Initiliazing motion...'); -[rn,vn,dt,fn,fseg]=feval(integrator,rn,dt,dt0,MU,NU,a,Ec,links,connectivity,... - rmax,rntol,mobility,vertices,uhat,nc,xnodes,D,mx,mz,w,h,d); +[rn, vn, dt, fn, fseg] = feval(integrator, rn, dt, dt0, MU, NU, a, Ec, links, connectivity, ... + rmax, rntol, mobility, vertices, uhat, nc, xnodes, D, mx, mz, w, h, d); simTime = simTime + dt; -rnnew=[rn(:,1:3) vn rn(:,4)]; -linksnew=links; -connectivitynew=connectivity; -linksinconnectnew=linksinconnect; -fsegnew=fseg; +rnnew = [rn(:, 1:3) vn rn(:, 4)]; +linksnew = links; +connectivitynew = connectivity; +linksinconnectnew = linksinconnect; +fsegnew = fseg; if (doseparation) %spliting of nodes with 4 or more connections - [rnnew,linksnew,connectivitynew,linksinconnectnew,fsegnew]=... - separation(rnnew,linksnew,connectivitynew,linksinconnectnew,... - fsegnew,mobility,MU,NU,a,Ec,2*rann,vertices,uhat,nc,xnodes,D,mx,mz,w,h,d); + [rnnew, linksnew, connectivitynew, linksinconnectnew, fsegnew] = ... + separation(rnnew, linksnew, connectivitynew, linksinconnectnew, ... + fsegnew, mobility, MU, NU, a, Ec, 2 * rann, vertices, uhat, nc, xnodes, D, mx, mz, w, h, d); end %save restart.mat -if (docollision) +if (docollision) %collision detection and handling - [colliding_segments]=CollisionCheckerMex(rnnew(:,1),rnnew(:,2),rnnew(:,3),rnnew(:,end),... - rnnew(:,4),rnnew(:,5),rnnew(:,6),linksnew(:,1),linksnew(:,2),connectivitynew,rann); - if colliding_segments == 1 %scan and update dislocation structure. - [rnnew,linksnew,connectivitynew,linksinconnectnew,fsegnew]=... - collision(rnnew,linksnew,connectivitynew,linksinconnectnew,... - fsegnew,rann,MU,NU,a,Ec,mobility,vertices,uhat,nc,xnodes,D,mx,mz,w,h,d); - end + [colliding_segments] = CollisionCheckerMex(rnnew(:, 1), rnnew(:, 2), rnnew(:, 3), rnnew(:, end), ... + rnnew(:, 4), rnnew(:, 5), rnnew(:, 6), linksnew(:, 1), linksnew(:, 2), connectivitynew, rann); + + if colliding_segments == 1%scan and update dislocation structure. + [rnnew, linksnew, connectivitynew, linksinconnectnew, fsegnew] = ... + collision(rnnew, linksnew, connectivitynew, linksinconnectnew, ... + fsegnew, rann, MU, NU, a, Ec, mobility, vertices, uhat, nc, xnodes, D, mx, mz, w, h, d); + end + end -if (doremesh) %do virtual re-meshing first +if (doremesh)%do virtual re-meshing first %remeshing virtual dislocation structures if (dovirtmesh) - [rnnew,linksnew,connectivitynew,linksinconnectnew,fsegnew]=virtualmeshcoarsen_mex(rnnew,linksnew,connectivitynew,linksinconnectnew,fsegnew,DIST_SOURCE*0.49,dx,MU,NU,a,Ec); + [rnnew, linksnew, connectivitynew, linksinconnectnew, fsegnew] = virtualmeshcoarsen_mex(rnnew, linksnew, connectivitynew, linksinconnectnew, fsegnew, DIST_SOURCE * 0.49, dx, MU, NU, a, Ec); end + %remeshing internal dislocation structures - [rnnew,linksnew,connectivitynew,linksinconnectnew,fsegnew]=remesh_all(rnnew,linksnew,connectivitynew,linksinconnectnew,fsegnew,lmin,lmax,areamin,areamax,MU,NU,a,Ec,mobility,doremesh,dovirtmesh,vertices,... - uhat,nc,xnodes,D,mx,mz,w,h,d,TriangleCentroids,TriangleNormals); -end -rnnew = rnnew(:,[1,2,3,7]); + [rnnew, linksnew, connectivitynew, linksinconnectnew, fsegnew] = remesh_all(rnnew, linksnew, connectivitynew, linksinconnectnew, fsegnew, lmin, lmax, areamin, areamax, MU, NU, a, Ec, mobility, doremesh, dovirtmesh, vertices, ... + uhat, nc, xnodes, D, mx, mz, w, h, d, TriangleCentroids, TriangleNormals); +end +rnnew = rnnew(:, [1, 2, 3, 7]); %% Compare displacement after remesh disp('Comparing pre-meshed and post-meshed displacements...'); disp('Pre-meshed:'); -[uhat,fend,Ubar] = FEMcoupler(rn,links,maxconnections,a,MU,NU,xnodes,mno,kg,L,U,... - gammau,gammat,gammaMixed,fixedDofs,freeDofs,dx,simTime); -fprintf('fend = %d, Ubar = %d, simTime = %d \n',fend,Ubar,simTime); +[uhat, fend, Ubar] = FEMcoupler(rn, links, maxconnections, a, MU, NU, xnodes, mno, kg, L, U, ... + gammau, gammat, gammaMixed, fixedDofs, freeDofs, dx, simTime); +fprintf('fend = %d, Ubar = %d, simTime = %d \n', fend, Ubar, simTime); disp('Post-meshed'); -[uhat_rem,fend_rem,Ubar_rem] = FEMcoupler(rnnew,linksnew,maxconnections,a,MU,NU,xnodes,mno,kg,L,U,... - gammau,gammat,gammaMixed,fixedDofs,freeDofs,dx,simTime); -fprintf('fend = %d, Ubar = %d, simTime = %d \n',fend_rem,Ubar_rem,simTime); - -fprintf('\n \n Error in fend = %d, Error in Ubar = %d\n',norm(fend_rem-fend),norm(Ubar_rem-Ubar)); +[uhat_rem, fend_rem, Ubar_rem] = FEMcoupler(rnnew, linksnew, maxconnections, a, MU, NU, xnodes, mno, kg, L, U, ... + gammau, gammat, gammaMixed, fixedDofs, freeDofs, dx, simTime); +fprintf('fend = %d, Ubar = %d, simTime = %d \n', fend_rem, Ubar_rem, simTime); +fprintf('\n \n Error in fend = %d, Error in Ubar = %d\n', norm(fend_rem - fend), norm(Ubar_rem - Ubar)); diff --git a/input/junctiondisplacement2.m b/input/junctiondisplacement2.m index 40b0c4cf..a8a3416e 100644 --- a/input/junctiondisplacement2.m +++ b/input/junctiondisplacement2.m @@ -3,7 +3,7 @@ global Bscrew Bedge Beclimb Bline l = 250; -b = 0.5*[1 1 1]; +b = 0.5 * [1 1 1]; side1 = [1 -2 1]; side2 = [2 -1 -1]; @@ -12,193 +12,197 @@ side5 = [-2 1 1]; side6 = [-1 -1 2]; -n1 = cross(side1,b); -n2 = cross(side2,b); -n3 = cross(side3,b); -n4 = cross(side4,b); -n5 = cross(side5,b); -n6 = cross(side6,b); +n1 = cross(side1, b); +n2 = cross(side2, b); +n3 = cross(side3, b); +n4 = cross(side4, b); +n5 = cross(side5, b); +n6 = cross(side6, b); %start from center of grid % Loop 1 A1 = [2500 2500 1500]; -A2 = A1 + l*side1; -A3 = A2 + l*side2; -A4 = A3 + l*side3; -A5 = A4 + l*side4; -A6 = A5 + l*side5; +A2 = A1 + l * side1; +A3 = A2 + l * side2; +A4 = A3 + l * side3; +A5 = A4 + l * side4; +A6 = A5 + l * side5; % Loop 2 -B1 = (side1+side2)*l; -B2 = B1 + l*side1; -B3 = B2 + l*side2; -B4 = B3 + l*side3; -B5 = B4 + l*side4; -B6 = B5 + l*side5; - -alpha=180; +B1 = (side1 + side2) * l; +B2 = B1 + l * side1; +B3 = B2 + l * side2; +B4 = B3 + l * side3; +B5 = B4 + l * side4; +B6 = B5 + l * side5; + +alpha = 180; %vector=[623.4277 499.2138 125.0000]; %vector=[-125 -750 -375]; vector = [1000 -500 0]; -R = [cosd(alpha), -sind(alpha), 0 ; sind(alpha), cosd(alpha), 0; 0, 0, 1]; -B1 = (R*B1')'; B2 = (R*B2')'; B3 = (R*B3')'; B4 = (R*B4')'; B5 = (R*B5')'; B6 = (R*B6')'; -B1=B1+A1+vector; B2=B2+A1+vector; B3=B3+A1+vector; B4=B4+A1+vector; B5=B5+A1+vector; B6=B6+A1+vector; -n7 = (R*n1')'; n8 = (R*n2')'; n9 = (R*n3')'; n10 = (R*n4')'; n11 = (R*n5')'; n12 = (R*n6')'; -b1 = (R*b')'; +R = [cosd(alpha), -sind(alpha), 0; sind(alpha), cosd(alpha), 0; 0, 0, 1]; +B1 = (R * B1')'; B2 = (R * B2')'; B3 = (R * B3')'; B4 = (R * B4')'; B5 = (R * B5')'; B6 = (R * B6')'; +B1 = B1 + A1 + vector; B2 = B2 + A1 + vector; B3 = B3 + A1 + vector; B4 = B4 + A1 + vector; B5 = B5 + A1 + vector; B6 = B6 + A1 + vector; +n7 = (R * n1')'; n8 = (R * n2')'; n9 = (R * n3')'; n10 = (R * n4')'; n11 = (R * n5')'; n12 = (R * n6')'; +b1 = (R * b')'; b1 = [-1 1 0] -rn = [ - A1, 0; - A2, 0; - A3, 0; - A4, 0; - A5, 0; - A6, 0; - - B1, 0; - B2, 0; - B3, 0; - B4, 0; - B5, 0; - B6, 0; - ]; - -links = [ 1 2 b n1; - 2 3 b n2; - 3 4 b n3; - 4 5 b n4; - 5 6 b n5; - 6 1 b n6; - - 7 8 b1 n7; - 8 9 b1 n8; - 9 10 b1 n9; - 10 11 b1 n10; - 11 12 b1 n11; - 12 7 b1 n12; - ]; - -MU = 1; -NU = 0.305; -maxconnections=8; -lmax = 1000; -lmin = 100; -areamin=lmin*lmin*sin(60/180*pi)*0.5; -areamax=20*areamin; -a=lmin/sqrt(3)*0.5; -Ec = MU/(4*pi)*log(a/0.1); -dt0=100; -mobility='mobbcc0'; +rn = [ + A1, 0; + A2, 0; + A3, 0; + A4, 0; + A5, 0; + A6, 0; + + B1, 0; + B2, 0; + B3, 0; + B4, 0; + B5, 0; + B6, 0; + ]; + +links = [1 2 b n1; + 2 3 b n2; + 3 4 b n3; + 4 5 b n4; + 5 6 b n5; + 6 1 b n6; + + 7 8 b1 n7; + 8 9 b1 n8; + 9 10 b1 n9; + 10 11 b1 n10; + 11 12 b1 n11; + 12 7 b1 n12; + ]; + +MU = 1; +NU = 0.305; +maxconnections = 8; +lmax = 1000; +lmin = 100; +areamin = lmin * lmin * sin(60/180 * pi) * 0.5; +areamax = 20 * areamin; +a = lmin / sqrt(3) * 0.5; +Ec = MU / (4 * pi) * log(a / 0.1); +dt0 = 100; +mobility = 'mobbcc0'; intSimTime = 0; sinTime = 0; -dtplot=3e6;% 3 ms (code in units of ns) -doplot=1;% frame recording: 1 == on, 0 == off +dtplot = 3e6; % 3 ms (code in units of ns) +doplot = 1; % frame recording: 1 == on, 0 == off totalSimTime = 0.3e12; curstep = 0; simTime = 0; -Bscrew=1e0; -Bedge=1e0; -Beclimb=1e10; -Bline=1.0e-4*min(Bscrew,Bedge); +Bscrew = 1e0; +Bedge = 1e0; +Beclimb = 1e10; +Bline = 1.0e-4 * min(Bscrew, Bedge); global USING_GPU; -USING_GPU=0; %0 if CPU only. - -integrator='int_trapezoid'; -rann = 0.5*a; -rntol = 0.5*rann; -doremesh=1; %flat set to 0 or 1 that turns the remesh functions off or on -docollision=1; %flat set to 0 or 1 that turns collision detection off or on -doseparation=1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on -dovirtmesh=1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on -plotfreq=1; -plim=7000; -appliedstress =10^-2*[2 0 1; 0 2 -1; 1 -1 0]; -viewangle=[90 0 ]; -printfreq=1; -printnode=1; -rmax=100; %maximum distance a node may travel in one cycle +USING_GPU = 0; %0 if CPU only. + +integrator = 'int_trapezoid'; +rann = 0.5 * a; +rntol = 0.5 * rann; +doremesh = 1; %flat set to 0 or 1 that turns the remesh functions off or on +docollision = 1; %flat set to 0 or 1 that turns collision detection off or on +doseparation = 1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on +dovirtmesh = 1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on +plotFreq = 1; +plim = 7000; +appliedstress = 10^ - 2 * [2 0 1; 0 2 -1; 1 -1 0]; +viewangle = [90 0]; +printfreq = 1; +printnode = 1; +rmax = 100; %maximum distance a node may travel in one cycle %FEM CANTILEVER PARAMETERS a_mag = 3.18e-4; -dx=8; %microns -dy=2; %microns -dz=2; %microns +dx = 8; %microns +dy = 2; %microns +dz = 2; %microns %tungsten "a" is 0.000274 -dx = dx/a_mag; -dy = dy/a_mag; -dz = dz/a_mag; -DIST_SOURCE = 0.5/a_mag; - -mx=20; -loading=1; -vertices = [0,0,0;... - dx,0,0;... - 0,dy,0;... - dx,dy,0;... - 0,0,dz;... - dx,0,dz;... - 0,dy,dz;... - dx,dy,dz]; - -plotHandle = plotnodes(rn,links,plim,vertices); view(viewangle); +dx = dx / a_mag; +dy = dy / a_mag; +dz = dz / a_mag; +DIST_SOURCE = 0.5 / a_mag; + +mx = 20; +loading = 1; +vertices = [0, 0, 0; ... + dx, 0, 0; ... + 0, dy, 0; ... + dx, dy, 0; ... + 0, 0, dz; ... + dx, 0, dz; ... + 0, dy, dz; ... + dx, dy, dz]; + +plotHandle = plotnodes(rn, links, plim, vertices); view(viewangle); %% -if(~exist('dt','var')) - dt=dt0; +if (~exist('dt', 'var')) + dt = dt0; end -dt=min(dt,dt0); -disp('Initiliazing connectivity list. Please wait.'); -[connectivity,linksinconnect]=genconnectivity(rn,links,maxconnections); +dt = min(dt, dt0); -disp('Constructing stiffness matrix K and precomputing L,U decompositions. Please wait.'); -[B,xnodes,mno,nc,n,D,kg,K,L,U,Sleft,Sright,Stop,Sbot,... - Sfront,Sback,gammat,gammau,gammaMixed,fixedDofs,freeDofs,... - w,h,d,my,mz,mel] = finiteElement3D(dx,dy,dz,mx,MU,NU,loading); +disp('Initiliazing connectivity list. Please wait.'); +[connectivity, linksinconnect] = genconnectivity(rn, links, maxconnections); -disp('Creating surface mesh. Please wait.'); -[TriangleCentroids,TriangleNormals,tri,Xb] = ... - MeshSurfaceTriangulation(xnodes,Stop,Sbot,Sfront,Sback,Sleft,Sright); +disp('Constructing stiffness matrix K and precomputing L,U decompositions. Please wait.'); +[B, xnodes, mno, nc, n, D, kg, K, L, U, Sleft, Sright, Stop, Sbot, ... + Sfront, Sback, gammat, gammau, gammaMixed, fixedDofs, freeDofs, ... + w, h, d, my, mz, mel] = finiteElement3D(dx, dy, dz, mx, MU, NU, loading); -disp('Calculating displacements from segments. Please wait.'); -[uhat,~,~] = FEMcoupler(rn,links,maxconnections,a,MU,NU,xnodes,mno,kg,L,U,... - gammau,gammat,gammaMixed,fixedDofs,freeDofs,dx,simTime); +disp('Creating surface mesh. Please wait.'); +[TriangleCentroids, TriangleNormals, tri, Xb] = ... + MeshSurfaceTriangulation(xnodes, Stop, Sbot, Sfront, Sback, Sleft, Sright); + +disp('Calculating displacements from segments. Please wait.'); +[uhat, ~, ~] = FEMcoupler(rn, links, maxconnections, a, MU, NU, xnodes, mno, kg, L, U, ... + gammau, gammat, gammaMixed, fixedDofs, freeDofs, dx, simTime); %fprintf('fend = %d, Ubar = %d, simTime = %d \n',fend,Ubar,simTime); disp('Initiliazing motion...'); -[rn,vn,dt,fn,fseg]=feval(integrator,rn,dt,dt0,MU,NU,a,Ec,links,connectivity,... - rmax,rntol,mobility,vertices,uhat,nc,xnodes,D,mx,mz,w,h,d); +[rn, vn, dt, fn, fseg] = feval(integrator, rn, dt, dt0, MU, NU, a, Ec, links, connectivity, ... + rmax, rntol, mobility, vertices, uhat, nc, xnodes, D, mx, mz, w, h, d); simTime = simTime + dt; -rnnew=[rn(:,1:3) vn rn(:,4)]; -linksnew=links; -connectivitynew=connectivity; -linksinconnectnew=linksinconnect; -fsegnew=fseg; +rnnew = [rn(:, 1:3) vn rn(:, 4)]; +linksnew = links; +connectivitynew = connectivity; +linksinconnectnew = linksinconnect; +fsegnew = fseg; if (doseparation) %spliting of nodes with 4 or more connections - [rnnew,linksnew,connectivitynew,linksinconnectnew,fsegnew]=... - separation(rnnew,linksnew,connectivitynew,linksinconnectnew,... - fsegnew,mobility,MU,NU,a,Ec,2*rann,vertices,uhat,nc,xnodes,D,mx,mz,w,h,d); + [rnnew, linksnew, connectivitynew, linksinconnectnew, fsegnew] = ... + separation(rnnew, linksnew, connectivitynew, linksinconnectnew, ... + fsegnew, mobility, MU, NU, a, Ec, 2 * rann, vertices, uhat, nc, xnodes, D, mx, mz, w, h, d); end %save restart.mat -if (docollision) +if (docollision) %collision detection and handling - [colliding_segments]=CollisionCheckerMex(rnnew(:,1),rnnew(:,2),rnnew(:,3),rnnew(:,end),... - rnnew(:,4),rnnew(:,5),rnnew(:,6),linksnew(:,1),linksnew(:,2),connectivitynew,rann); - if 1%colliding_segments == 1 %scan and update dislocation structure. - [rnnew,linksnew,connectivitynew,linksinconnectnew,fsegnew]=... - collision(rnnew,linksnew,connectivitynew,linksinconnectnew,... - fsegnew,rann,MU,NU,a,Ec,mobility,vertices,uhat,nc,xnodes,D,mx,mz,w,h,d); - end + [colliding_segments] = CollisionCheckerMex(rnnew(:, 1), rnnew(:, 2), rnnew(:, 3), rnnew(:, end), ... + rnnew(:, 4), rnnew(:, 5), rnnew(:, 6), linksnew(:, 1), linksnew(:, 2), connectivitynew, rann); + + if 1%colliding_segments == 1%scan and update dislocation structure. + [rnnew, linksnew, connectivitynew, linksinconnectnew, fsegnew] = ... + collision(rnnew, linksnew, connectivitynew, linksinconnectnew, ... + fsegnew, rann, MU, NU, a, Ec, mobility, vertices, uhat, nc, xnodes, D, mx, mz, w, h, d); + end + end -% + +% % if (doremesh) %do virtual re-meshing first % %remeshing virtual dislocation structures % if (dovirtmesh) @@ -207,22 +211,20 @@ % %remeshing internal dislocation structures % [rnnew,linksnew,connectivitynew,linksinconnectnew,fsegnew]=remesh_all(rnnew,linksnew,connectivitynew,linksinconnectnew,fsegnew,lmin,lmax,areamin,areamax,MU,NU,a,Ec,mobility,doremesh,dovirtmesh,vertices,... % uhat,nc,xnodes,D,mx,mz,w,h,d,TriangleCentroids,TriangleNormals); -% end +% end %rnnew = rnnew(:,[1,2,3,7]); - %% Compare displacement after remesh disp('Comparing pre-meshed and post-meshed displacements...'); disp('Pre-meshed:'); -[uhat,fend,Ubar] = FEMcoupler(rn,links,maxconnections,a,MU,NU,xnodes,mno,kg,L,U,... - gammau,gammat,gammaMixed,fixedDofs,freeDofs,dx,simTime); -fprintf('fend = %d, Ubar = %d, simTime = %d \n',fend,Ubar,simTime); +[uhat, fend, Ubar] = FEMcoupler(rn, links, maxconnections, a, MU, NU, xnodes, mno, kg, L, U, ... + gammau, gammat, gammaMixed, fixedDofs, freeDofs, dx, simTime); +fprintf('fend = %d, Ubar = %d, simTime = %d \n', fend, Ubar, simTime); disp('Post-meshed'); -[uhat_rem,fend_rem,Ubar_rem] = FEMcoupler(rnnew,linksnew,maxconnections,a,MU,NU,xnodes,mno,kg,L,U,... - gammau,gammat,gammaMixed,fixedDofs,freeDofs,dx,simTime); -fprintf('fend = %d, Ubar = %d, simTime = %d \n',fend_rem,Ubar_rem,simTime); - -fprintf('\n \n Error in fend = %d, Error in Ubar = %d\n',norm(fend_rem-fend),norm(Ubar_rem-Ubar)); +[uhat_rem, fend_rem, Ubar_rem] = FEMcoupler(rnnew, linksnew, maxconnections, a, MU, NU, xnodes, mno, kg, L, U, ... + gammau, gammat, gammaMixed, fixedDofs, freeDofs, dx, simTime); +fprintf('fend = %d, Ubar = %d, simTime = %d \n', fend_rem, Ubar_rem, simTime); +fprintf('\n \n Error in fend = %d, Error in Ubar = %d\n', norm(fend_rem - fend), norm(Ubar_rem - Ubar)); diff --git a/input/junctiondisplacement3.m b/input/junctiondisplacement3.m index 7bc471b4..959a81fe 100644 --- a/input/junctiondisplacement3.m +++ b/input/junctiondisplacement3.m @@ -16,174 +16,177 @@ side3b = [0 -1 0]; side4b = [-1 0 -1]; -n1 = cross(side1,b1); -n2 = cross(side2,b1); -n3 = cross(side3,b1); -n4 = cross(side4,b1); +n1 = cross(side1, b1); +n2 = cross(side2, b1); +n3 = cross(side3, b1); +n4 = cross(side4, b1); -n1b = cross(side1b,b2); -n2b = cross(side2b,b2); -n3b = cross(side3b,b2); -n4b = cross(side4b,b2); +n1b = cross(side1b, b2); +n2b = cross(side2b, b2); +n3b = cross(side3b, b2); +n4b = cross(side4b, b2); %start from center of grid % Loop 1 A1 = [2500 2500 1500]; -A2 = A1 + l*side1; -A3 = A2 + l*side2; -A4 = A3 + l*side3; +A2 = A1 + l * side1; +A3 = A2 + l * side2; +A4 = A3 + l * side3; % Loop 2 -B1 = A2+[0 0 0]; -B2 = B1 + l*side1b; -B3 = B2 + l*side2b; -B4 = B3 + l*side3b; - - -rn = [ - A1, 0; - A2, 0; - A3, 0; - A4, 0; - - B1, 0; - B2, 0; - B3, 0; - B4, 0; - ]; - -links = [ 1 2 b1 n1; - 2 3 b1 n2; - 3 4 b1 n3; - 4 1 b1 n4; - - 5 6 b2 n1b; - 6 7 b2 n2b; - 7 8 b2 n3b; - 8 5 b2 n4b; - ]; - -MU = 1; -NU = 0.305; -maxconnections=8; -lmax = 1000; -lmin = 100; -areamin=lmin*lmin*sin(60/180*pi)*0.5; -areamax=20*areamin; -a=lmin/sqrt(3)*0.5; -Ec = MU/(4*pi)*log(a/0.1); -dt0=100; -mobility='mobbcc0'; +B1 = A2 + [0 0 0]; +B2 = B1 + l * side1b; +B3 = B2 + l * side2b; +B4 = B3 + l * side3b; + +rn = [ + A1, 0; + A2, 0; + A3, 0; + A4, 0; + + B1, 0; + B2, 0; + B3, 0; + B4, 0; + ]; + +links = [1 2 b1 n1; + 2 3 b1 n2; + 3 4 b1 n3; + 4 1 b1 n4; + + 5 6 b2 n1b; + 6 7 b2 n2b; + 7 8 b2 n3b; + 8 5 b2 n4b; + ]; + +MU = 1; +NU = 0.305; +maxconnections = 8; +lmax = 1000; +lmin = 100; +areamin = lmin * lmin * sin(60/180 * pi) * 0.5; +areamax = 20 * areamin; +a = lmin / sqrt(3) * 0.5; +Ec = MU / (4 * pi) * log(a / 0.1); +dt0 = 100; +mobility = 'mobbcc0'; intSimTime = 0; sinTime = 0; -dtplot=3e6;% 3 ms (code in units of ns) -doplot=1;% frame recording: 1 == on, 0 == off +dtplot = 3e6; % 3 ms (code in units of ns) +doplot = 1; % frame recording: 1 == on, 0 == off totalSimTime = 0.3e12; curstep = 0; simTime = 0; -Bscrew=1e0; -Bedge=1e0; -Beclimb=1e10; -Bline=1.0e-4*min(Bscrew,Bedge); +Bscrew = 1e0; +Bedge = 1e0; +Beclimb = 1e10; +Bline = 1.0e-4 * min(Bscrew, Bedge); global USING_GPU; -USING_GPU=0; %0 if CPU only. - -integrator='int_trapezoid'; -rann = 0.5*a; -rntol = 0.5*rann; -doremesh=1; %flat set to 0 or 1 that turns the remesh functions off or on -docollision=1; %flat set to 0 or 1 that turns collision detection off or on -doseparation=1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on -dovirtmesh=1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on -plotfreq=1; -plim=7000; -appliedstress =10^-2*[2 0 1; 0 2 -1; 1 -1 0]; -viewangle=[90 0 ]; -printfreq=1; -printnode=1; -rmax=100; %maximum distance a node may travel in one cycle +USING_GPU = 0; %0 if CPU only. + +integrator = 'int_trapezoid'; +rann = 0.5 * a; +rntol = 0.5 * rann; +doremesh = 1; %flat set to 0 or 1 that turns the remesh functions off or on +docollision = 1; %flat set to 0 or 1 that turns collision detection off or on +doseparation = 1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on +dovirtmesh = 1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on +plotFreq = 1; +plim = 7000; +appliedstress = 10^ - 2 * [2 0 1; 0 2 -1; 1 -1 0]; +viewangle = [90 0]; +printfreq = 1; +printnode = 1; +rmax = 100; %maximum distance a node may travel in one cycle %FEM CANTILEVER PARAMETERS a_mag = 3.18e-4; -dx=8; %microns -dy=2; %microns -dz=2; %microns +dx = 8; %microns +dy = 2; %microns +dz = 2; %microns %tungsten "a" is 0.000274 -dx = dx/a_mag; -dy = dy/a_mag; -dz = dz/a_mag; -DIST_SOURCE = 0.5/a_mag; - -mx=20; -loading=1; -vertices = [0,0,0;... - dx,0,0;... - 0,dy,0;... - dx,dy,0;... - 0,0,dz;... - dx,0,dz;... - 0,dy,dz;... - dx,dy,dz]; - -plotHandle = plotnodes(rn,links,plim,vertices); view(viewangle); +dx = dx / a_mag; +dy = dy / a_mag; +dz = dz / a_mag; +DIST_SOURCE = 0.5 / a_mag; + +mx = 20; +loading = 1; +vertices = [0, 0, 0; ... + dx, 0, 0; ... + 0, dy, 0; ... + dx, dy, 0; ... + 0, 0, dz; ... + dx, 0, dz; ... + 0, dy, dz; ... + dx, dy, dz]; + +plotHandle = plotnodes(rn, links, plim, vertices); view(viewangle); %% -if(~exist('dt','var')) - dt=dt0; +if (~exist('dt', 'var')) + dt = dt0; end -dt=min(dt,dt0); -disp('Initiliazing connectivity list. Please wait.'); -[connectivity,linksinconnect]=genconnectivity(rn,links,maxconnections); +dt = min(dt, dt0); -disp('Constructing stiffness matrix K and precomputing L,U decompositions. Please wait.'); -[B,xnodes,mno,nc,n,D,kg,K,L,U,Sleft,Sright,Stop,Sbot,... - Sfront,Sback,gammat,gammau,gammaMixed,fixedDofs,freeDofs,... - w,h,d,my,mz,mel] = finiteElement3D(dx,dy,dz,mx,MU,NU,loading); +disp('Initiliazing connectivity list. Please wait.'); +[connectivity, linksinconnect] = genconnectivity(rn, links, maxconnections); -disp('Creating surface mesh. Please wait.'); -[TriangleCentroids,TriangleNormals,tri,Xb] = ... - MeshSurfaceTriangulation(xnodes,Stop,Sbot,Sfront,Sback,Sleft,Sright); +disp('Constructing stiffness matrix K and precomputing L,U decompositions. Please wait.'); +[B, xnodes, mno, nc, n, D, kg, K, L, U, Sleft, Sright, Stop, Sbot, ... + Sfront, Sback, gammat, gammau, gammaMixed, fixedDofs, freeDofs, ... + w, h, d, my, mz, mel] = finiteElement3D(dx, dy, dz, mx, MU, NU, loading); -disp('Calculating displacements from segments. Please wait.'); -[uhat,~,~] = FEMcoupler(rn,links,maxconnections,a,MU,NU,xnodes,mno,kg,L,U,... - gammau,gammat,gammaMixed,fixedDofs,freeDofs,dx,simTime); +disp('Creating surface mesh. Please wait.'); +[TriangleCentroids, TriangleNormals, tri, Xb] = ... + MeshSurfaceTriangulation(xnodes, Stop, Sbot, Sfront, Sback, Sleft, Sright); + +disp('Calculating displacements from segments. Please wait.'); +[uhat, ~, ~] = FEMcoupler(rn, links, maxconnections, a, MU, NU, xnodes, mno, kg, L, U, ... + gammau, gammat, gammaMixed, fixedDofs, freeDofs, dx, simTime); %fprintf('fend = %d, Ubar = %d, simTime = %d \n',fend,Ubar,simTime); disp('Initiliazing motion...'); -[rn,vn,dt,fn,fseg]=feval(integrator,rn,dt,dt0,MU,NU,a,Ec,links,connectivity,... - rmax,rntol,mobility,vertices,uhat,nc,xnodes,D,mx,mz,w,h,d); +[rn, vn, dt, fn, fseg] = feval(integrator, rn, dt, dt0, MU, NU, a, Ec, links, connectivity, ... + rmax, rntol, mobility, vertices, uhat, nc, xnodes, D, mx, mz, w, h, d); simTime = simTime + dt; -rnnew=[rn(:,1:3) vn rn(:,4)]; -linksnew=links; -connectivitynew=connectivity; -linksinconnectnew=linksinconnect; -fsegnew=fseg; +rnnew = [rn(:, 1:3) vn rn(:, 4)]; +linksnew = links; +connectivitynew = connectivity; +linksinconnectnew = linksinconnect; +fsegnew = fseg; if (doseparation) %spliting of nodes with 4 or more connections - [rnnew,linksnew,connectivitynew,linksinconnectnew,fsegnew]=... - separation(rnnew,linksnew,connectivitynew,linksinconnectnew,... - fsegnew,mobility,MU,NU,a,Ec,2*rann,vertices,uhat,nc,xnodes,D,mx,mz,w,h,d); + [rnnew, linksnew, connectivitynew, linksinconnectnew, fsegnew] = ... + separation(rnnew, linksnew, connectivitynew, linksinconnectnew, ... + fsegnew, mobility, MU, NU, a, Ec, 2 * rann, vertices, uhat, nc, xnodes, D, mx, mz, w, h, d); end %save restart.mat -if (docollision) +if (docollision) %collision detection and handling - [colliding_segments]=CollisionCheckerMex(rnnew(:,1),rnnew(:,2),rnnew(:,3),rnnew(:,end),... - rnnew(:,4),rnnew(:,5),rnnew(:,6),linksnew(:,1),linksnew(:,2),connectivitynew,rann); - if 1%colliding_segments == 1 %scan and update dislocation structure. - [rnnew,linksnew,connectivitynew,linksinconnectnew,fsegnew]=... - collision(rnnew,linksnew,connectivitynew,linksinconnectnew,... - fsegnew,rann,MU,NU,a,Ec,mobility,vertices,uhat,nc,xnodes,D,mx,mz,w,h,d); - end + [colliding_segments] = CollisionCheckerMex(rnnew(:, 1), rnnew(:, 2), rnnew(:, 3), rnnew(:, end), ... + rnnew(:, 4), rnnew(:, 5), rnnew(:, 6), linksnew(:, 1), linksnew(:, 2), connectivitynew, rann); + + if 1%colliding_segments == 1%scan and update dislocation structure. + [rnnew, linksnew, connectivitynew, linksinconnectnew, fsegnew] = ... + collision(rnnew, linksnew, connectivitynew, linksinconnectnew, ... + fsegnew, rann, MU, NU, a, Ec, mobility, vertices, uhat, nc, xnodes, D, mx, mz, w, h, d); + end + end -% + +% % if (doremesh) %do virtual re-meshing first % %remeshing virtual dislocation structures % if (dovirtmesh) @@ -192,22 +195,20 @@ % %remeshing internal dislocation structures % [rnnew,linksnew,connectivitynew,linksinconnectnew,fsegnew]=remesh_all(rnnew,linksnew,connectivitynew,linksinconnectnew,fsegnew,lmin,lmax,areamin,areamax,MU,NU,a,Ec,mobility,doremesh,dovirtmesh,vertices,... % uhat,nc,xnodes,D,mx,mz,w,h,d,TriangleCentroids,TriangleNormals); -% end +% end %rnnew = rnnew(:,[1,2,3,7]); - %% Compare displacement after remesh disp('Comparing pre-meshed and post-meshed displacements...'); disp('Pre-meshed:'); -[uhat,fend,Ubar] = FEMcoupler(rn,links,maxconnections,a,MU,NU,xnodes,mno,kg,L,U,... - gammau,gammat,gammaMixed,fixedDofs,freeDofs,dx,simTime); -fprintf('fend = %d, Ubar = %d, simTime = %d \n',fend,Ubar,simTime); +[uhat, fend, Ubar] = FEMcoupler(rn, links, maxconnections, a, MU, NU, xnodes, mno, kg, L, U, ... + gammau, gammat, gammaMixed, fixedDofs, freeDofs, dx, simTime); +fprintf('fend = %d, Ubar = %d, simTime = %d \n', fend, Ubar, simTime); disp('Post-meshed'); -[uhat_rem,fend_rem,Ubar_rem] = FEMcoupler(rnnew,linksnew,maxconnections,a,MU,NU,xnodes,mno,kg,L,U,... - gammau,gammat,gammaMixed,fixedDofs,freeDofs,dx,simTime); -fprintf('fend = %d, Ubar = %d, simTime = %d \n',fend_rem,Ubar_rem,simTime); - -fprintf('\n \n Error in fend = %d, Error in Ubar = %d\n',norm(fend_rem-fend),norm(Ubar_rem-Ubar)); +[uhat_rem, fend_rem, Ubar_rem] = FEMcoupler(rnnew, linksnew, maxconnections, a, MU, NU, xnodes, mno, kg, L, U, ... + gammau, gammat, gammaMixed, fixedDofs, freeDofs, dx, simTime); +fprintf('fend = %d, Ubar = %d, simTime = %d \n', fend_rem, Ubar_rem, simTime); +fprintf('\n \n Error in fend = %d, Error in Ubar = %d\n', norm(fend_rem - fend), norm(Ubar_rem - Ubar)); diff --git a/input/loop_100_generator.m b/input/loop_100_generator.m index 38d41d6b..274a1e30 100644 --- a/input/loop_100_generator.m +++ b/input/loop_100_generator.m @@ -3,103 +3,103 @@ global Bscrew Bedge Beclimb Bline b = [0 0 1]; -b1= [0 0 1]; +b1 = [0 0 1]; -P1 = [(7.2993e+03-1000) (1.8248e+03-1000) 1.8248e+03+1000]; -P2 = [(7.2993e+03+1000) (1.8248e+03-1000) 1.8248e+03+1000]; -P3 = [(7.2993e+03+1000) (1.8248e+03+1000) 1.8248e+03+1000]; -P4 = [(7.2993e+03-1000) (1.8248e+03+1000) 1.8248e+03+1000]; +P1 = [(7.2993e+03 - 1000) (1.8248e+03 - 1000) 1.8248e+03 + 1000]; +P2 = [(7.2993e+03 + 1000) (1.8248e+03 - 1000) 1.8248e+03 + 1000]; +P3 = [(7.2993e+03 + 1000) (1.8248e+03 + 1000) 1.8248e+03 + 1000]; +P4 = [(7.2993e+03 - 1000) (1.8248e+03 + 1000) 1.8248e+03 + 1000]; -P5 = [(7.2993e+03-1000) (1.8248e+03-1000) 1.8248e+03-1000]; -P6 = [(7.2993e+03+1000) (1.8248e+03-1000) 1.8248e+03-1000]; -P7 = [(7.2993e+03+1000) (1.8248e+03+1000) 1.8248e+03-1000]; -P8 = [(7.2993e+03-1000) (1.8248e+03+1000) 1.8248e+03-1000]; +P5 = [(7.2993e+03 - 1000) (1.8248e+03 - 1000) 1.8248e+03 - 1000]; +P6 = [(7.2993e+03 + 1000) (1.8248e+03 - 1000) 1.8248e+03 - 1000]; +P7 = [(7.2993e+03 + 1000) (1.8248e+03 + 1000) 1.8248e+03 - 1000]; +P8 = [(7.2993e+03 - 1000) (1.8248e+03 + 1000) 1.8248e+03 - 1000]; -rn = [ - P1, 0; - P2, 0; - P3, 0; - P4, 0; - P5, 0; - P6, 0; - P7, 0; - P8, 0; - ]; - -n1 = cross(P2-P1,b); -n2 = cross(P3-P2,b); -n3 = cross(P4-P3,b); -n4 = cross(P4-P1,b); +rn = [ + P1, 0; + P2, 0; + P3, 0; + P4, 0; + P5, 0; + P6, 0; + P7, 0; + P8, 0; + ]; -links = [ 1 4 b n1; - 4 3 b n2; - 3 2 b n3; - 2 1 b n4; - 8 5 b1 n1; - 5 6 b1 n4; - 6 7 b1 n3; - 7 8 b1 n2; - - ]; - -MU = 1; -NU = 0.305; -maxconnections=8; -lmax = 1000; -lmin = 50; -coplanar_tol = lmin*0.5; -areamin=lmin*lmin*sin(60/180*pi)*0.5; -areamax=20*areamin; -a=lmin/sqrt(3)*0.5; -Ec = MU/(4*pi)*log(a/0.1); -dt0=1e7; -mobility='mobbcc0'; +n1 = cross(P2 - P1, b); +n2 = cross(P3 - P2, b); +n3 = cross(P4 - P3, b); +n4 = cross(P4 - P1, b); + +links = [1 4 b n1; + 4 3 b n2; + 3 2 b n3; + 2 1 b n4; + 8 5 b1 n1; + 5 6 b1 n4; + 6 7 b1 n3; + 7 8 b1 n2; + + ]; + +MU = 1; +NU = 0.305; +maxconnections = 8; +lmax = 1000; +lmin = 50; +coplanar_tol = lmin * 0.5; +areamin = lmin * lmin * sin(60/180 * pi) * 0.5; +areamax = 20 * areamin; +a = lmin / sqrt(3) * 0.5; +Ec = MU / (4 * pi) * log(a / 0.1); +dt0 = 1e7; +mobility = 'mobbcc0'; intSimTime = 0; sinTime = 0; -dtplot=3e6;% 3 ms (code in units of ns) -doplot=1;% frame recording: 1 == on, 0 == off +dtplot = 3e6; % 3 ms (code in units of ns) +doplot = 1; % frame recording: 1 == on, 0 == off totalSimTime = 0.3e12; curstep = 0; simTime = 0; -Bscrew=1e0; -Bedge=1e0; -Beclimb=1e10; -Bline=1.0e-4*min(Bscrew,Bedge); +Bscrew = 1e0; +Bedge = 1e0; +Beclimb = 1e10; +Bline = 1.0e-4 * min(Bscrew, Bedge); -integrator='int_trapezoid'; -rann = 0.5*a; -rntol = 0.5*rann; -doremesh=1; %flat set to 0 or 1 that turns the remesh functions off or on -docollision=1; %flat set to 0 or 1 that turns collision detection off or on -doseparation=1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on -dovirtmesh=1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on -plotfreq=1; -plim=7000; -appliedstress =0*[2 0 1; 0 2 -1; 1 -1 0]; -viewangle=[-35,15]; -printfreq=1; -printnode=3; -rmax=100; %maximum distance a node may travel in one cycle +integrator = 'int_trapezoid'; +rann = 0.5 * a; +rntol = 0.5 * rann; +doremesh = 1; %flat set to 0 or 1 that turns the remesh functions off or on +docollision = 1; %flat set to 0 or 1 that turns collision detection off or on +doseparation = 1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on +dovirtmesh = 1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on +plotFreq = 1; +plim = 7000; +appliedstress = 0 * [2 0 1; 0 2 -1; 1 -1 0]; +viewangle = [-35, 15]; +printfreq = 1; +printnode = 3; +rmax = 100; %maximum distance a node may travel in one cycle %FEM CANTILEVER PARAMETERS -dx=6; %microns -dy=1; %microns -dz=1; %microns +dx = 6; %microns +dy = 1; %microns +dz = 1; %microns %tungsten "a" is 0.000274 -dx = dx/0.000274; -dy = dy/0.000274; -dz = dz/0.000274; +dx = dx / 0.000274; +dy = dy / 0.000274; +dz = dz / 0.000274; -mx=12; % number of elements along beam length -loading=1; -vertices = [0,0,0;... - dx,0,0;... - 0,dy,0;... - dx,dy,0;... - 0,0,dz;... - dx,0,dz;... - 0,dy,dz;... - dx,dy,dz]; +mx = 12; % number of elements along beam length +loading = 1; +vertices = [0, 0, 0; ... + dx, 0, 0; ... + 0, dy, 0; ... + dx, dy, 0; ... + 0, 0, dz; ... + dx, 0, dz; ... + 0, dy, dz; ... + dx, dy, dz]; diff --git a/input/loop_101_generator.m b/input/loop_101_generator.m index 0fadca90..a0644525 100644 --- a/input/loop_101_generator.m +++ b/input/loop_101_generator.m @@ -4,17 +4,15 @@ bmag = 2.74E-4; -l = 0.5/bmag; +l = 0.5 / bmag; b = [1 0 1]; - -side1 = [-1 0 1]; +side1 = [-1 0 1]; side2 = [0 -1 0]; side3 = -side1; side4 = -side2; - -n = cross(side2,b); +n = cross(side2, b); %start from center of grid @@ -22,153 +20,153 @@ %P1 = [0.52 0.1 0.52]/bmag; %lateral %Loop n.1, inside [101] -P1 = [1.52 1.2 1.2]/bmag; -P2m = P1 + l*side1*0.5; -P2 = P1 + l*side1; -P3m = P2 + l*side2*0.5; -P3 = P2 + l*side2; -P4 = P3 + l*side3; -P4m = P3 + l*side3*0.5; -P1m = P4 + l*side4*0.5; +P1 = [1.52 1.2 1.2] / bmag; +P2m = P1 + l * side1 * 0.5; +P2 = P1 + l * side1; +P3m = P2 + l * side2 * 0.5; +P3 = P2 + l * side2; +P4 = P3 + l * side3; +P4m = P3 + l * side3 * 0.5; +P1m = P4 + l * side4 * 0.5; %Loop n.2, inside [101] -P5 = [2.52 1.2 1.2]/bmag; -P6m = P5 + l*side1*0.5; -P6 = P5 + l*side1; -P7m = P6 + l*side2*0.5; -P7 = P6 + l*side2; -P8 = P7 + l*side3; -P8m = P7 + l*side3*0.5; -P5m = P8 + l*side4*0.5; +P5 = [2.52 1.2 1.2] / bmag; +P6m = P5 + l * side1 * 0.5; +P6 = P5 + l * side1; +P7m = P6 + l * side2 * 0.5; +P7 = P6 + l * side2; +P8 = P7 + l * side3; +P8m = P7 + l * side3 * 0.5; +P5m = P8 + l * side4 * 0.5; %Loop n.3, inside [101] -P9 = [4.52 1.2 1.2]/bmag; -P10m = P9 + l*side1*0.5; -P10 = P9 + l*side1; -P11m = P10 + l*side2*0.5; -P11 = P10 + l*side2; -P12 = P11 + l*side3; -P12m = P11 + l*side3*0.5; -P9m = P9 + l*side4*0.5; - -rn = [ - P1, 7; - P2m, 0; - P2, 7; - P3m, 0; - P3, 7; - P4m, 0; - P4, 7; - P1m, 0; - - P5, 7; - P6m, 0; - P6, 7; - P7m, 0; - P7, 7; - P8m, 0; - P8, 7; - P5m, 0; - - P9, 7; - P10m, 0; - P10, 7; - P11m, 0; - P11, 7; - P12m, 0; - P12, 7; - P9m, 0; - ]; - -links = [ 2 1 b n; - 3 2 b n; - 4 3 b n; - 5 4 b n; - 6 5 b n; - 7 6 b n; - 8 7 b n; - 1 8 b n; - - 2+8 1+8 b n; - 3+8 2+8 b n; - 4+8 3+8 b n; - 5+8 4+8 b n; - 6+8 5+8 b n; - 7+8 6+8 b n; - 8+8 7+8 b n; - 1+8 8+8 b n; - - 2+16 1+16 b n; - 3+16 2+16 b n; - 4+16 3+16 b n; - 5+16 4+16 b n; - 6+16 5+16 b n; - 7+16 6+16 b n; - 8+16 7+16 b n; - 1+16 8+16 b n; - ]; - -MU = 1; -NU = 0.305; -maxconnections=8; -lmax = 500; -lmin = 100; +P9 = [4.52 1.2 1.2] / bmag; +P10m = P9 + l * side1 * 0.5; +P10 = P9 + l * side1; +P11m = P10 + l * side2 * 0.5; +P11 = P10 + l * side2; +P12 = P11 + l * side3; +P12m = P11 + l * side3 * 0.5; +P9m = P9 + l * side4 * 0.5; + +rn = [ + P1, 7; + P2m, 0; + P2, 7; + P3m, 0; + P3, 7; + P4m, 0; + P4, 7; + P1m, 0; + + P5, 7; + P6m, 0; + P6, 7; + P7m, 0; + P7, 7; + P8m, 0; + P8, 7; + P5m, 0; + + P9, 7; + P10m, 0; + P10, 7; + P11m, 0; + P11, 7; + P12m, 0; + P12, 7; + P9m, 0; + ]; + +links = [2 1 b n; + 3 2 b n; + 4 3 b n; + 5 4 b n; + 6 5 b n; + 7 6 b n; + 8 7 b n; + 1 8 b n; + + 2 + 8 1 + 8 b n; + 3 + 8 2 + 8 b n; + 4 + 8 3 + 8 b n; + 5 + 8 4 + 8 b n; + 6 + 8 5 + 8 b n; + 7 + 8 6 + 8 b n; + 8 + 8 7 + 8 b n; + 1 + 8 8 + 8 b n; + + 2 + 16 1 + 16 b n; + 3 + 16 2 + 16 b n; + 4 + 16 3 + 16 b n; + 5 + 16 4 + 16 b n; + 6 + 16 5 + 16 b n; + 7 + 16 6 + 16 b n; + 8 + 16 7 + 16 b n; + 1 + 16 8 + 16 b n; + ]; + +MU = 1; +NU = 0.305; +maxconnections = 8; +lmax = 500; +lmin = 100; coplanar_tol = 10; -areamin=lmin*lmin*sin(60/180*pi)*0.5; -areamax=20*areamin; -a=lmin/sqrt(3)*0.5; -Ec = MU/(4*pi)*log(a/0.1); -dt0=1e5; -mobility='mobbcc0'; +areamin = lmin * lmin * sin(60/180 * pi) * 0.5; +areamax = 20 * areamin; +a = lmin / sqrt(3) * 0.5; +Ec = MU / (4 * pi) * log(a / 0.1); +dt0 = 1e5; +mobility = 'mobbcc0'; intSimTime = 0; sinTime = 0; -dtplot=5e5; -doplot=1;% frame recording: 1 == on, 0 == off +dtplot = 5e5; +doplot = 1; % frame recording: 1 == on, 0 == off totalSimTime = 0.3e12; curstep = 0; simTime = 0; -Bscrew=1e0; -Bedge=1e0; -Beclimb=1e10; -Bline=1.0e-4*min(Bscrew,Bedge); - -integrator='int_trapezoid'; -rann = 0.5*a; -rntol = 0.5*rann; -doremesh=1; %flat set to 0 or 1 that turns the remesh functions off or on -docollision=1; %flat set to 0 or 1 that turns collision detection off or on -doseparation=1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on -dovirtmesh=1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on -plotfreq=1; -plim=7000; -viewangle=[-35,15]; -printfreq=1; -printnode=4; -rmax=100; %maximum distance a node may travel in one cycle +Bscrew = 1e0; +Bedge = 1e0; +Beclimb = 1e10; +Bline = 1.0e-4 * min(Bscrew, Bedge); + +integrator = 'int_trapezoid'; +rann = 0.5 * a; +rntol = 0.5 * rann; +doremesh = 1; %flat set to 0 or 1 that turns the remesh functions off or on +docollision = 1; %flat set to 0 or 1 that turns collision detection off or on +doseparation = 1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on +dovirtmesh = 1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on +plotFreq = 1; +plim = 7000; +viewangle = [-35, 15]; +printfreq = 1; +printnode = 4; +rmax = 100; %maximum distance a node may travel in one cycle %FEM CANTILEVER PARAMETERS -dx=12; %microns -dy=2; %microns -dz=2; %microns +dx = 12; %microns +dy = 2; %microns +dz = 2; %microns %tungsten "a" is 0.000274 -dx = dx/bmag; -dy = dy/bmag; -dz = dz/bmag; - -mx=30; % number of elements along beam length -loading=1; -vertices = [0,0,0;... - dx,0,0;... - 0,dy,0;... - dx,dy,0;... - 0,0,dz;... - dx,0,dz;... - 0,dy,dz;... - dx,dy,dz]; +dx = dx / bmag; +dy = dy / bmag; +dz = dz / bmag; + +mx = 30; % number of elements along beam length +loading = 1; +vertices = [0, 0, 0; ... + dx, 0, 0; ... + 0, dy, 0; ... + dx, dy, 0; ... + 0, 0, dz; ... + dx, 0, dz; ... + 0, dy, dz; ... + dx, dy, dz]; %plotnodes(rn,links,plim,vertices); hold on; -plot3(rn(:,1), rn(:,2), rn(:,3),'ko'); %nodes +plot3(rn(:, 1), rn(:, 2), rn(:, 3), 'ko'); %nodes diff --git a/input/loop_101_generator_SI.m b/input/loop_101_generator_SI.m index 86e05e7c..f33cdf0b 100644 --- a/input/loop_101_generator_SI.m +++ b/input/loop_101_generator_SI.m @@ -7,12 +7,12 @@ l = 2.5E-7; b = [1 0 1]; -side1 = [-1 0 1]; +side1 = [-1 0 1]; side2 = [0 -1 0]; side3 = -side1; side4 = -side2; -n = cross(side2,b); +n = cross(side2, b); %start from center of grid @@ -20,150 +20,150 @@ %P1 = [0.52 0.1 0.52]/bmag; %lateral %Loop n.1, inside [101] -P1 = [1.52 1.2 1.2]*10E-7; -P2m = P1 + l*side1*0.5; -P2 = P1 + l*side1; -P3m = P2 + l*side2*0.5; -P3 = P2 + l*side2; -P4 = P3 + l*side3; -P4m = P3 + l*side3*0.5; -P1m = P4 + l*side4*0.5; +P1 = [1.52 1.2 1.2] * 10E-7; +P2m = P1 + l * side1 * 0.5; +P2 = P1 + l * side1; +P3m = P2 + l * side2 * 0.5; +P3 = P2 + l * side2; +P4 = P3 + l * side3; +P4m = P3 + l * side3 * 0.5; +P1m = P4 + l * side4 * 0.5; %Loop n.2, inside [101] -P5 = [2.52 1.2 1.2]*10E-7; -P6m = P5 + l*side1*0.5; -P6 = P5 + l*side1; -P7m = P6 + l*side2*0.5; -P7 = P6 + l*side2; -P8 = P7 + l*side3; -P8m = P7 + l*side3*0.5; -P5m = P8 + l*side4*0.5; +P5 = [2.52 1.2 1.2] * 10E-7; +P6m = P5 + l * side1 * 0.5; +P6 = P5 + l * side1; +P7m = P6 + l * side2 * 0.5; +P7 = P6 + l * side2; +P8 = P7 + l * side3; +P8m = P7 + l * side3 * 0.5; +P5m = P8 + l * side4 * 0.5; %Loop n.3, inside [101] -P9 = [4.52 1.2 1.2]*10E-7; -P10m = P9 + l*side1*0.5; -P10 = P9 + l*side1; -P11m = P10 + l*side2*0.5; -P11 = P10 + l*side2; -P12 = P11 + l*side3; -P12m = P11 + l*side3*0.5; -P9m = P9 + l*side4*0.5; - -rn = [ - P1, 7; - P2m, 0; - P2, 7; - P3m, 0; - P3, 7; - P4m, 0; - P4, 7; - P1m, 0; - - P5, 7; - P6m, 0; - P6, 7; - P7m, 0; - P7, 7; - P8m, 0; - P8, 7; - P5m, 0; - - P9, 7; - P10m, 0; - P10, 7; - P11m, 0; - P11, 7; - P12m, 0; - P12, 7; - P9m, 0; - ]; - -links = [ 2 1 b n; - 3 2 b n; - 4 3 b n; - 5 4 b n; - 6 5 b n; - 7 6 b n; - 8 7 b n; - 1 8 b n; - - 2+8 1+8 b n; - 3+8 2+8 b n; - 4+8 3+8 b n; - 5+8 4+8 b n; - 6+8 5+8 b n; - 7+8 6+8 b n; - 8+8 7+8 b n; - 1+8 8+8 b n; - - 2+16 1+16 b n; - 3+16 2+16 b n; - 4+16 3+16 b n; - 5+16 4+16 b n; - 6+16 5+16 b n; - 7+16 6+16 b n; - 8+16 7+16 b n; - 1+16 8+16 b n; - ]; - - links(:,3:5) = links(:,3:5)*bmag; - -MU = 160E9; -NU = 0.305; -maxconnections=4; -lmax = 1E-7; -lmin = 2.5E-8; -areamin=lmin*lmin*sin(60/180*pi)*0.5; -areamax=20*areamin; -a=lmin/sqrt(3)*0.5; -Ec = MU/(4*pi)*log(a/0.1); -dt0=1E-12; -mobility='mobbcc0'; +P9 = [4.52 1.2 1.2] * 10E-7; +P10m = P9 + l * side1 * 0.5; +P10 = P9 + l * side1; +P11m = P10 + l * side2 * 0.5; +P11 = P10 + l * side2; +P12 = P11 + l * side3; +P12m = P11 + l * side3 * 0.5; +P9m = P9 + l * side4 * 0.5; + +rn = [ + P1, 7; + P2m, 0; + P2, 7; + P3m, 0; + P3, 7; + P4m, 0; + P4, 7; + P1m, 0; + + P5, 7; + P6m, 0; + P6, 7; + P7m, 0; + P7, 7; + P8m, 0; + P8, 7; + P5m, 0; + + P9, 7; + P10m, 0; + P10, 7; + P11m, 0; + P11, 7; + P12m, 0; + P12, 7; + P9m, 0; + ]; + +links = [2 1 b n; + 3 2 b n; + 4 3 b n; + 5 4 b n; + 6 5 b n; + 7 6 b n; + 8 7 b n; + 1 8 b n; + + 2 + 8 1 + 8 b n; + 3 + 8 2 + 8 b n; + 4 + 8 3 + 8 b n; + 5 + 8 4 + 8 b n; + 6 + 8 5 + 8 b n; + 7 + 8 6 + 8 b n; + 8 + 8 7 + 8 b n; + 1 + 8 8 + 8 b n; + + 2 + 16 1 + 16 b n; + 3 + 16 2 + 16 b n; + 4 + 16 3 + 16 b n; + 5 + 16 4 + 16 b n; + 6 + 16 5 + 16 b n; + 7 + 16 6 + 16 b n; + 8 + 16 7 + 16 b n; + 1 + 16 8 + 16 b n; + ]; + +links(:, 3:5) = links(:, 3:5) * bmag; + +MU = 160E9; +NU = 0.305; +maxconnections = 4; +lmax = 1E-7; +lmin = 2.5E-8; +areamin = lmin * lmin * sin(60/180 * pi) * 0.5; +areamax = 20 * areamin; +a = lmin / sqrt(3) * 0.5; +Ec = MU / (4 * pi) * log(a / 0.1); +dt0 = 1E-12; +mobility = 'mobbcc0'; intSimTime = 0; sinTime = 0; -dtplot=1E-8; -doplot=1;% frame recording: 1 == on, 0 == off +dtplot = 1E-8; +doplot = 1; % frame recording: 1 == on, 0 == off totalSimTime = 1; curstep = 0; simTime = 0; -Bscrew=1e-5; -Bedge=1e-4; -Beclimb=1e5; -Bline=1.0e-4*min(Bscrew,Bedge); - -integrator='int_trapezoid'; -rann = 0.5*a; -rntol = 0.5*rann; -doremesh=1; %flat set to 0 or 1 that turns the remesh functions off or on -docollision=1; %flat set to 0 or 1 that turns collision detection off or on -doseparation=1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on -dovirtmesh=1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on -plotfreq=1; -plim=7000; -viewangle=[-35,15]; -printfreq=1; -printnode=4; -rmax=100; %maximum distance a node may travel in one cycle +Bscrew = 1e-5; +Bedge = 1e-4; +Beclimb = 1e5; +Bline = 1.0e-4 * min(Bscrew, Bedge); + +integrator = 'int_trapezoid'; +rann = 0.5 * a; +rntol = 0.5 * rann; +doremesh = 1; %flat set to 0 or 1 that turns the remesh functions off or on +docollision = 1; %flat set to 0 or 1 that turns collision detection off or on +doseparation = 1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on +dovirtmesh = 1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on +plotFreq = 1; +plim = 7000; +viewangle = [-35, 15]; +printfreq = 1; +printnode = 4; +rmax = 100; %maximum distance a node may travel in one cycle %FEM CANTILEVER PARAMETERS -dx=12E-6; %m, or 12 micron -dy=2E-6; -dz=2E-6; - -mx=30; % number of elements along beam length -loading=1; -vertices = [0,0,0;... - dx,0,0;... - 0,dy,0;... - dx,dy,0;... - 0,0,dz;... - dx,0,dz;... - 0,dy,dz;... - dx,dy,dz]; - -plotnodes(rn,links,plim,vertices); +dx = 12E-6; %m, or 12 micron +dy = 2E-6; +dz = 2E-6; + +mx = 30; % number of elements along beam length +loading = 1; +vertices = [0, 0, 0; ... + dx, 0, 0; ... + 0, dy, 0; ... + dx, dy, 0; ... + 0, 0, dz; ... + dx, 0, dz; ... + 0, dy, dz; ... + dx, dy, dz]; + +plotnodes(rn, links, plim, vertices); hold on; -plot3(rn(:,1), rn(:,2), rn(:,3),'ko'); %nodes +plot3(rn(:, 1), rn(:, 2), rn(:, 3), 'ko'); %nodes diff --git a/input/loop_111_generator.m b/input/loop_111_generator.m index 0dccf7b4..b146f43a 100644 --- a/input/loop_111_generator.m +++ b/input/loop_111_generator.m @@ -12,98 +12,98 @@ side5 = [-2 1 1]; side6 = [-1 -1 2]; -n1 = cross(side1,b); -n2 = cross(side2,b); -n3 = cross(side3,b); -n4 = cross(side4,b); -n5 = cross(side5,b); -n6 = cross(side6,b); +n1 = cross(side1, b); +n2 = cross(side2, b); +n3 = cross(side3, b); +n4 = cross(side4, b); +n5 = cross(side5, b); +n6 = cross(side6, b); %start from center of grid P1 = [10000 2000 500]; -P2 = P1 + l*side1; -P3 = P2 + l*side2; -P4 = P3 + l*side3; -P5 = P4 + l*side4; -P6 = P5 + l*side5; - -P7 = P6 + l*side6; %should equal P1, consistency check - -rn = [ - P1, 0; - P2, 0; - P3, 0; - P4, 0; - P5, 0; - P6, 0; - ]; - -links = [ 1 2 b n1; - 2 3 b n2; - 3 4 b n3; - 4 5 b n4; - 5 6 b n5; - 6 1 b n6; - ]; - -MU = 1; -NU = 0.305; -maxconnections=8; -lmax = 1000; -lmin = 100; -areamin=lmin*lmin*sin(60/180*pi)*0.5; -areamax=20*areamin; -a=lmin/sqrt(3)*0.5; -Ec = MU/(4*pi)*log(a/0.1); -dt0=1e5; -mobility='mobbcc0'; +P2 = P1 + l * side1; +P3 = P2 + l * side2; +P4 = P3 + l * side3; +P5 = P4 + l * side4; +P6 = P5 + l * side5; + +P7 = P6 + l * side6; %should equal P1, consistency check + +rn = [ + P1, 0; + P2, 0; + P3, 0; + P4, 0; + P5, 0; + P6, 0; + ]; + +links = [1 2 b n1; + 2 3 b n2; + 3 4 b n3; + 4 5 b n4; + 5 6 b n5; + 6 1 b n6; + ]; + +MU = 1; +NU = 0.305; +maxconnections = 8; +lmax = 1000; +lmin = 100; +areamin = lmin * lmin * sin(60/180 * pi) * 0.5; +areamax = 20 * areamin; +a = lmin / sqrt(3) * 0.5; +Ec = MU / (4 * pi) * log(a / 0.1); +dt0 = 1e5; +mobility = 'mobbcc0'; intSimTime = 0; sinTime = 0; -dtplot=3e6;% 3 ms (code in units of ns) -doplot=1;% frame recording: 1 == on, 0 == off +dtplot = 3e6; % 3 ms (code in units of ns) +doplot = 1; % frame recording: 1 == on, 0 == off totalSimTime = 0.3e12; curstep = 0; simTime = 0; -Bscrew=1e0; -Bedge=1e0; -Beclimb=1e10; -Bline=1.0e-4*min(Bscrew,Bedge); - -integrator='int_trapezoid'; -rann = 0.5*a; -rntol = 0.5*rann; -doremesh=1; %flat set to 0 or 1 that turns the remesh functions off or on -docollision=1; %flat set to 0 or 1 that turns collision detection off or on -doseparation=1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on -dovirtmesh=1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on -plotfreq=1; -plim=7000; -appliedstress =10^-2*[2 0 1; 0 2 -1; 1 -1 0]; -viewangle=[90 0 ]; -printfreq=1; -printnode=3; -rmax=100; %maximum distance a node may travel in one cycle +Bscrew = 1e0; +Bedge = 1e0; +Beclimb = 1e10; +Bline = 1.0e-4 * min(Bscrew, Bedge); + +integrator = 'int_trapezoid'; +rann = 0.5 * a; +rntol = 0.5 * rann; +doremesh = 1; %flat set to 0 or 1 that turns the remesh functions off or on +docollision = 1; %flat set to 0 or 1 that turns collision detection off or on +doseparation = 1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on +dovirtmesh = 1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on +plotFreq = 1; +plim = 7000; +appliedstress = 10^ - 2 * [2 0 1; 0 2 -1; 1 -1 0]; +viewangle = [90 0]; +printfreq = 1; +printnode = 3; +rmax = 100; %maximum distance a node may travel in one cycle %FEM CANTILEVER PARAMETERS -dx=4; %microns -dy=1; %microns -dz=1; %microns +dx = 4; %microns +dy = 1; %microns +dz = 1; %microns %tungsten "a" is 0.000274 -dx = dx/0.000274; -dy = dy/0.000274; -dz = dz/0.000274; - -mx=10; -loading=1; -vertices = [0,0,0;... - dx,0,0;... - 0,dy,0;... - dx,dy,0;... - 0,0,dz;... - dx,0,dz;... - 0,dy,dz;... - dx,dy,dz]; +dx = dx / 0.000274; +dy = dy / 0.000274; +dz = dz / 0.000274; + +mx = 10; +loading = 1; +vertices = [0, 0, 0; ... + dx, 0, 0; ... + 0, dy, 0; ... + dx, dy, 0; ... + 0, 0, dz; ... + dx, 0, dz; ... + 0, dy, dz; ... + dx, dy, dz]; diff --git a/input/source_generator.m b/input/source_generator.m index e25e136b..f1509714 100644 --- a/input/source_generator.m +++ b/input/source_generator.m @@ -24,91 +24,90 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% SOURCE GENERATION PARAMETERS -amag=3.14E-10; +amag = 3.14E-10; CRYSTAL_STRUCTURE = 'bcc'; NUM_SOURCES = 1; -DIST_SOURCE = 35*10E-9/amag; +DIST_SOURCE = 35 * 10E-9 / amag; %% FEM PARAMETERS %Cantilever -dx=12E-6/amag; %12micron -dy=2E-6/amag; %2micron -dz=2E-6/amag; %2micron - -mx=50; % number of elements along beam length -loading=1; -vertices = [0,0,0;... - dx,0,0;... - 0,dy,0;... - dx,dy,0;... - 0,0,dz;... - dx,0,dz;... - 0,dy,dz;... - dx,dy,dz]; +dx = 12E-6 / amag; %12micron +dy = 2E-6 / amag; %2micron +dz = 2E-6 / amag; %2micron + +mx = 50; % number of elements along beam length +loading = 1; +vertices = [0, 0, 0; ... + dx, 0, 0; ... + 0, dy, 0; ... + dx, dy, 0; ... + 0, 0, dz; ... + dx, 0, dz; ... + 0, dy, dz; ... + dx, dy, dz]; %% MATERIAL CONSTANTS %MU = 160E9; %160GPa MU = 1; -NU = 0.305; +NU = 0.305; %% DDLab PARAMETERS %Dislocation nodes and segments generator %[rn,links] = DislocationSourceGenerator(NUM_SOURCES,DIST_SOURCE,CRYSTAL_STRUCTURE,dx,dy,dz,5); -[rn,links] = checkGenerator101(NUM_SOURCES,DIST_SOURCE,CRYSTAL_STRUCTURE,dx,dy,dz); +[rn, links] = checkGenerator101(NUM_SOURCES, DIST_SOURCE, CRYSTAL_STRUCTURE, dx, dy, dz); %Edge and screw glide and climb mobility parameters -mobility='mobbcc0'; +mobility = 'mobbcc0'; global Bscrew Bedge Beclimb Bline %Bedge=1e-4; %Pa s %Bscrew=1e-5; %Pa s %Beclimb=1e5; %Pa s - really big %Bline=1e-4*min(Bscrew,Bedge); -Bedge=1; -Bscrew=0.1; -Beclimb=1e15; -Bline=1e-4*min(Bscrew,Bedge); +Bedge = 1; +Bscrew = 0.1; +Beclimb = 1e15; +Bline = 1e-4 * min(Bscrew, Bedge); %Meshing -maxconnections=4; -lmax = 20*10E-9/amag; %20nm -lmin = 1*10E-9/amag; %1nm -areamin=lmin*lmin*sin(60/180*pi)*0.5; -areamax=20*areamin; -doremesh=1; %flat set to 0 or 1 that turns the remesh functions off or on -docollision=1; %flat set to 0 or 1 that turns collision detection off or on -doseparation=1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on -dovirtmesh=1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on +maxconnections = 4; +lmax = 20 * 10E-9 / amag; %20nm +lmin = 1 * 10E-9 / amag; %1nm +areamin = lmin * lmin * sin(60/180 * pi) * 0.5; +areamax = 20 * areamin; +doremesh = 1; %flat set to 0 or 1 that turns the remesh functions off or on +docollision = 1; %flat set to 0 or 1 that turns collision detection off or on +doseparation = 1; %flat set to 0 or 1 that turns splitting algorithm for highly connected node off or on +dovirtmesh = 1; %flat set to 0 or 1 that turns remeshing of virtual nodes off or on %Simulation time -dt0=10E-9; +dt0 = 10E-9; %dt0=10E4; intSimTime = 0; sinTime = 0; %dtplot=2E-9; %2ns -dtplot=1E5; -doplot=1; % frame recording: 1 == on, 0 == off +dtplot = 1E5; +doplot = 1; % frame recording: 1 == on, 0 == off totalSimTime = 10E12; curstep = 0; simTime = 0; %Integrator -integrator='int_trapezoid'; -%integrator='int_trapezoid_stoc'; %in development -a=lmin/sqrt(3)*0.5; -Ec = MU/(4*pi)*log(a/0.1); -rann = 0.5*a; -rntol = 0.5*rann; +integrator = 'int_trapezoid'; +%integrator='int_trapezoid_stoc'; %in development +a = lmin / sqrt(3) * 0.5; +Ec = MU / (4 * pi) * log(a / 0.1); +rann = 0.5 * a; +rntol = 0.5 * rann; rmax = lmin; %Plotting -plotfreq=10; -plim=12E-6/amag; %12microns -viewangle=[-35,15]; -printfreq=1; -printnode=4; - +plotFreq = 10; +plim = 12E-6 / amag; %12microns +viewangle = [-35, 15]; +printfreq = 1; +printnode = 4; diff --git a/src/EasyDD.m b/src/EasyDD.m index 896063ed..75dbb2b9 100644 --- a/src/EasyDD.m +++ b/src/EasyDD.m @@ -52,7 +52,6 @@ % input provide a default. % TODO: #11 in remesh_surf, make it so dislocations do not leave the domain via % the fixed end depending on the simulation type. -% TODO: #13 remove globals % [fList, pList] = matlab.codetools.requiredFilesAndProducts('dd3d_next.m'); % fList(:) @@ -71,16 +70,14 @@ consistencycheck(rn, links, connectivity, linksinconnect); % Construct stiffeness matrix K and pre-compute L,U decompositions. -% gammat -> nodes where tractions = f(x) -% gammau -> nodes where displacements = u(x) -% gammaLoad -> nodes where tractions = df(x) -% gammaDisp -> nodes where displacements = du(x) -% use feval() for loading rate. -% TODO #14: Split FE part from boundary conditions. -[vertices, B, xnodes, mno, nc, n, D, kg, K, L, U, Sleft, Sright, Stop, ... - Sbot, Sfront, Sback, gammat, gammau, gammaMixed, fixedDofs, ... - freeDofs, w, h, d, my, mz, mel] = finiteElement3D(dx, dy, dz, mx, ... - MU, NU, loading); +[vertices, B, xnodes, mno, nc, n, D, kg, w, h, d, my, mz, mel] = ... + finiteElement3D(dx, dy, dz, mx, MU, NU); + +[K, L, U, Sleft, Sright, Stop, Sbot, Sfront, Sback, Smixed, gammat, ... + gammau, gammaMixed, fixedDofs, freeDofs, processForceDisp, plotForceDisp] = ... + feval(simType, kg, w, h, d, mx, my, mz); + +plotFEMDomain(Stop, Sbot, Sright, Sleft, Sfront, Sback, Smixed, xnodes) % Construct data structures needed for analytic tractions. [f, f_hat, para_tol, x3x6, n_se, gamma_dln, f_tilda_node, f_tilda_se, f_tilda, ... @@ -103,13 +100,11 @@ u_tilda_0 = calculateUtilda(rn, links, gamma_disp, NU, xnodes, dx, ... dy, dz, mx, my, mz, u_tilda_0); -disp('Initialisation complete.'); +fprintf('Initialisation complete.\n'); while simTime < totalSimTime % DDD+FEM coupling - - % TODO: Add requirements to make Haiyang's and Fengxian's simulations easy to do. [f_bar, f_hat, f_tilda, u_bar, u_hat, u_tilda, r_hat] = FEM_DDD_Superposition(... rn, links, a, MU, NU, xnodes, kg, L, U, gamma_disp, gammaMixed, fixedDofs, ... freeDofs, dx, dy, dz, simTime, mx, my, mz, sign_u_dot, u_dot, sign_f_dot, ... @@ -117,13 +112,8 @@ n_nodes_t, n_se, idxi, f, f_tilda_node, f_tilda_se, f_tilda, f_hat, CUDA_flag, ... n_threads, para_scheme, para_tol); - % TODO: turn this into feval() - [f_out, u_out] = processForceDisp(f_bar, f_hat, f_tilda, u_bar, u_hat, u_tilda, ... - r_hat, gamma_disp, gammaMixed, fixedDofs, freeDofs, simType); - - [Fsim, Usim, t] = updateForceDispTime(Fsim, Usim, t, f_out, u_out, simTime, curstep, simType); - - fprintf('fend = %d, Ubar = %d, simTime = %d \n', f_out, u_out, simTime); + [Fsim, Usim, t] = feval(processForceDisp, Fsim, f_bar, f_hat, f_tilda, Usim, u_bar, u_hat, u_tilda, ... + r_hat, gammaMixed, fixedDofs, freeDofs, curstep, simTime); %integrating equation of motion [rnnew, vn, dt, fn, fseg] = feval(integrator, rn, dt, dt0, MU, NU, a, Ec, links, connectivity, ... @@ -132,129 +122,48 @@ % plastic strain and plastic spin calculations [ep_inc, wp_inc] = calcPlasticStrainIncrement(rnnew, rn, links, (2 * plim)^3); - if (mod(curstep, plotfreq) == 0) - plotnodes(rn, links, plim, vertices); - view(viewangle); - %schematicplot2(rn,links,vertices,U_bar,Fend,amag,dx,totalSimTime); - drawnow - pause(0.01); - % - % figure(2); - % clf - % plot(U_bar*bmag,-Fend*bmag^2*mumag) - % pause(0.01); - end + plotSimulation(Usim, Fsim, rn, links, plim, vertices, plotFreq, viewangle, plotForceDisp, amag, mumag, curstep); [planeindex] = outofplanecheck(rn, links); - rnnew = [rnnew(:, 1:3) vn rnnew(:, 4)]; - linksnew = links; - connectivitynew = connectivity; - linksinconnectnew = linksinconnect; - fsegnew = fseg; - - if (doremesh)% do virtual re-meshing first - %remeshing virtual dislocation structures - if (dovirtmesh) - [rnnew, linksnew, connectivitynew, linksinconnectnew, fsegnew] = virtualmeshcoarsen(rnnew, linksnew, ... - connectivitynew, linksinconnectnew, fsegnew, MU, NU, a, Ec); - end - - %remeshing internal dislocation structures - [rnnew, linksnew, connectivitynew, linksinconnectnew, fsegnew] = remesh_all(rnnew, linksnew, ... - connectivitynew, linksinconnectnew, fsegnew, lmin, lmax, areamin, areamax, MU, NU, a, Ec, ... - mobility, doremesh, dovirtmesh, vertices, u_hat, nc, xnodes, D, mx, mz, w, h, d, ... - TriangleCentroids, TriangleNormals, CUDA_flag, Bcoeff); - end - - %save restart.mat - if (docollision) - s1_old = 0; - s2_old = 0; - - % Collision detection and handling - colliding_segments = 1; - - while colliding_segments == 1 - [colliding_segments, n1s1, n2s1, n1s2, n2s2, floop, s1, s2, segpair] = CollisionCheckerMex(rnnew(:, 1), rnnew(:, 2), rnnew(:, 3), rnnew(:, end), ... - rnnew(:, 4), rnnew(:, 5), rnnew(:, 6), linksnew(:, 1), linksnew(:, 2), connectivitynew, rann); - - if colliding_segments == 1%scan and update dislocation structure. - - if floop == 1 - fprintf("Step %d. Unconnected links found. Links %d and %d are colliding.\n", curstep, s1, s2) - elseif floop == 2 - fprintf("Step %d. Links %d and %d colliding by hinge condition.\n", curstep, s1, s2) - end - - if colliding_segments == 1 - [rnnew, linksnew, ~, ~, fsegnew, colliding_segments] = collision(rnnew, linksnew, connectivitynew, linksinconnectnew, fsegnew, rann, MU, NU, a, Ec, mobility, vertices, ... - u_hat, nc, xnodes, D, mx, mz, w, h, d, floop, n1s1, n2s1, n1s2, n2s2, s1, s2, segpair, lmin, CUDA_flag, Bcoeff); - - %removing links with effective zero Burgers vectors - [rnnew, linksnew, connectivitynew, linksinconnectnew, fsegnew] = cleanupsegments(rnnew, linksnew, fsegnew); - end + [rnnew, linksnew, connectivitynew, linksinconnectnew, fsegnew] = updateMatricesForward(rnnew, vn, links, connectivity, linksinconnect, fseg); - end - - end - - end - - %find blockading fixed nodes and allow code to deal with them - for i = 1:size(rnnew, 1) - - if rnnew(i, end) ~= 7 - continue - end - - if connectivitynew(i, 1) > 7 - rnnew(i, end) = 0; - end - - end + [rnnew, linksnew, connectivitynew, linksinconnectnew, fsegnew] = remeshPreCollision(rnnew, linksnew, ... + connectivitynew, linksinconnectnew, fsegnew, lmin, lmax, areamin, areamax, MU, NU, a, Ec, ... + mobility, doremesh, dovirtmesh, vertices, u_hat, nc, xnodes, D, mx, mz, w, h, d, ... + TriangleCentroids, TriangleNormals, CUDA_flag, Bcoeff); - if (doseparation) + [rnnew, linksnew, connectivitynew, linksinconnectnew, fsegnew] = collideNodesAndSegments(docollision, ... + rnnew, linksnew, connectivitynew, linksinconnectnew, fsegnew, rann, MU, NU, a, Ec, mobility, vertices, ... + u_hat, nc, xnodes, D, mx, mz, w, h, d, lmin, CUDA_flag, Bcoeff, curstep); - if max(connectivitynew(:, 1)) > 3 - %spliting of nodes with 4 or more connections - [rnnew, linksnew, connectivitynew, linksinconnectnew, fsegnew] = ... - separation(rnnew, linksnew, connectivitynew, linksinconnectnew, ... - fsegnew, mobility, MU, NU, a, Ec, 2 * rann, vertices, u_hat, nc, xnodes, D, mx, mz, w, h, d, CUDA_flag, Bcoeff); - end + rnnew = fixBlockadingNodes(rnnew); - end + [rnnew, linksnew, connectivitynew, linksinconnectnew, fsegnew] = ... + separation(doseparation, rnnew, linksnew, connectivitynew, linksinconnectnew, ... + fsegnew, mobility, MU, NU, a, Ec, 2 * rann, vertices, u_hat, nc, xnodes, D, mx, mz, w, h, d, CUDA_flag, Bcoeff); [rnnew, linksnew, connectivitynew, linksinconnectnew, fsegnew] = remesh_all(rnnew, linksnew, ... connectivitynew, linksinconnectnew, fsegnew, lmin, lmax, areamin, areamax, MU, NU, a, Ec, ... mobility, doremesh, 0, vertices, u_hat, nc, xnodes, D, mx, mz, w, h, d, TriangleCentroids, ... TriangleNormals, CUDA_flag, Bcoeff); - rn = [rnnew(:, 1:3) rnnew(:, 7)]; - vn = rnnew(:, 4:6); - links = linksnew; - connectivity = connectivitynew; - linksinconnect = linksinconnectnew; - fseg = fsegnew; - - %store run time information - %time step - curstep = curstep + 1; - %data(curstep,1)=dt; - simTime = simTime + dt; - - % save restart; - % if all(rn(:,4)==67) %no more real segments, stop simulation - % disp('Dislocation-free real domain. Only virtual segments remain!'); - % disp('Computing distorted mesh. Please wait...'); - % [u_tilda]=visualise(rn,links,NU,D,mx,my,mz,mel,mno,xnodes,nc,... - % dx,dy,dz,w,h,d,vertices,u_hat); - % return; - % end + [rn, vn, links, connectivity, linksinconnect, fseg] = updateMatricesBackward(rnnew, ... + linksnew, connectivitynew, linksinconnectnew, fsegnew); + + [curstep, simTime] = updateTime(curstep, simTime, dt); + + saveSimulation(simName, curstep, saveFreq) + + if ~any(rn(:, 4) == 0) + fprintf('No more real segments, ending simulation.\n') + saveSimulation(simName, curstep, saveFreq) + return; + end end -save restart; -disp('completed') +fprintf('Simulation completed.\n') +saveSimulation(simName, curstep, saveFreq) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/FEM_DDD_Superposition.m b/src/FEM_DDD_Superposition.m index a6cd6820..fa6057f2 100644 --- a/src/FEM_DDD_Superposition.m +++ b/src/FEM_DDD_Superposition.m @@ -12,20 +12,7 @@ f_hat(:, 1) = 0; f_tilda(:, 1) = 0; - if loading == 1% Displacement control. - f_bar = 0; - u_bar = u_dot * simTime; - u(3 * gamma_mixed(:, 1)) = sign_u_dot * u_bar; - elseif loading == 2% Force control. - u_bar = 0; - f_bar = f_dot * simTime; - f(3 * gamma_mixed(:, 1)) = sign_f_dot * f_bar; - else % Fallback, probably not physical - u_bar = u_dot * simTime; - u(3 * gamma_mixed(:, 1)) = sign_u_dot * u_bar; - f_bar = f_dot * t; - f(3 * gamma_mixed(:, 1)) = sign_f_dot * f_bar; - end + [u, u_bar, f, f_bar, calculateR_hat] = feval(loading, u, u_dot, sign_u_dot, f, f_dot, sign_f_dot, simTime, gamma_mixed); % Calculate adjusted U_tilda. u_tilda = calculateUtilda(rn, links, gamma_disp, NU, xnodes, dx, ... @@ -33,7 +20,7 @@ u_hat(fixedDofs) = u(fixedDofs) - u_tilda(fixedDofs); - if a_trac == true + if a_trac [x1x2, b, n_dln] = extract_dislocation_nodes(rn, links); [f_tilda, ~] = analytic_traction(x3x6, x1x2, b, n_nodes, n_nodes_t, ... n_se, n_dln, 3 * gamma_dln(:, 1), idxi, ... @@ -53,9 +40,11 @@ f(fixedDofs) = bcwt * u_hat(fixedDofs); u_hat = U \ (L \ f); %using LU decomposition - if loading ~= 2% If not using force control, calculate reaction force. + % If not using force control, calculate reaction force. + if calculateR_hat r_hat = kg * u_hat; - else % If using force control, don't calculate reaction force. + % If using force control, don't calculate reaction force. + else r_hat = 0; end diff --git a/src/analytic_traction.m b/src/analytic_traction.m index b5c2b41b..e09357c3 100644 --- a/src/analytic_traction.m +++ b/src/analytic_traction.m @@ -147,7 +147,7 @@ %% Analytical force calculation. % Parallel CUDA C calculation. % serial last dislocation and surface element - if CUDA_flag == true + if CUDA_flag % Provide a default number of threads in case none is given. if ~exist('n_threads', 'var') n_threads = ceil(mod(n_dln, 256) / 32) * 32; @@ -167,7 +167,7 @@ burgers(:), mu, nu, a, n_se, n_dln, n_threads, ... para_scheme, para_tol); % Serial force calculation in C. - elseif CUDA_flag == false + else [f_dln_node(:, 1), f_dln_node(:, 2), f_dln_node(:, 3), f_dln_node(:, 4), ... f_dln_se] = NodalSurfaceForceLinearRectangleMex(... dln_node_coord(:, 1), dln_node_coord(:, 2), ... diff --git a/src/cantileverBending.m b/src/cantileverBending.m new file mode 100644 index 00000000..b22ea860 --- /dev/null +++ b/src/cantileverBending.m @@ -0,0 +1,186 @@ +function [K, L, U, Sleft, Sright, Stop, Sbot, Sfront, Sback, Smixed, gammat, gammau,... + gammaMixed, fixedDofs, freeDofs, processForceDisp, plotForceDisp] = cantileverBending(... + kg, w, h, d, mx, my, mz) + + fprintf('Cantilever bending boundary conditions: reformatting K\n'); + + K = kg; + bcwt = mean(diag(kg)); %=trace(K)/length(K) + bcwt = full(bcwt); + + % define empty sets (not used but allows same code as for bending) + % priority for inclusion of shared nodes is in order below + %S = [node #, nodal Area, outward normal] + Smixed = zeros(my + 1, 5); % top right edge (u3=U) first priority + + Sleft = zeros((my + 1) * (mz + 1), 5); % second priority + Sright = zeros((my + 1) * mz, 3); + + Stop = zeros((mx - 1) * (my + 1), 5); % third priority + Sbot = zeros((mx - 1) * (my + 1), 5); + + Sfront = zeros((mz - 1) * (mx - 1), 5); % fourth priority + Sback = zeros((mz - 1) * (mx - 1), 5); + + m = 1; + + for j = 1:my + 1 + + for k = 1:mz + 1 + % left surface of beam (u=0) + gn = 1 + (k - 1) * (mx + 1) + (mx + 1) * (mz + 1) * (j - 1); + Sleft(m, 1) = gn; + + if k == 1 || k == mz + 1 + L3 = 0.5 * d; + else + L3 = d; + end + + if j == 1 || j == my + 1 + L2 = 0.5 * h; + else + L2 = h; + end + + Sleft(m, 2) = L2 * L3; + Sleft(m, 3:5) = [-1, 0, 0]; + m = m + 1; + end + + end + + m = 1; + + for j = 1:my + 1 + + for k = 1:mz + % right surface of beam (t=0) + gn = k * (mx + 1) + (mx + 1) * (mz + 1) * (j - 1); + Sright(m, 1) = gn; + + if k == 1 + L3 = 0.5 * d; + else + L3 = d; + end + + if j == 1 || j == my + 1 + L2 = 0.5 * h; + else + L2 = h; + end + + Sright(m, 2) = L2 * L3; + Sright(m, 3:5) = [1, 0, 0]; + m = m + 1; + end + + end + + m = 1; + + for j = 1:my + 1 + % top right loaded edge (t1=0, u2=-U) mixed surface + gn = (mx + 1) * (mz + 1) * j; + Smixed(m, 1) = gn; + + if j == 1 || j == my + 1 + L2 = 0.5 * h; + else + L2 = h; + end + + L3 = 0.5 * d; + Smixed(m, 2) = L2 * L3; + Smixed(m, 3:5) = [1, 0, 0]; + m = m + 1; + end + + m = 1; + + for j = 1:my + 1 + + for i = 2:mx + % bottom surface of beam (t=0) + gn = i + (mx + 1) * (mz + 1) * (j - 1); + Sbot(m, 1) = gn; + % top surface of beam (t=0) + gn = i + (mx + 1) * mz + (mx + 1) * (mz + 1) * (j - 1); + Stop(m, 1) = gn; + + L1 = w; + + if j == 1 || j == my + 1 + L2 = 0.5 * h; + else + L2 = h; + end + + Sbot(m, 2) = L1 * L2; + Sbot(m, 3:5) = [0, 0, -1]; + Stop(m, 2) = L1 * L2; + Stop(m, 3:5) = [0, 0, 1]; + m = m + 1; + end + + end + + m = 1; + + for k = 2:mz + + for i = 2:mx + %front surface of beam (t=0) + gn = i + (k - 1) * (mx + 1); + Sfront(m) = gn; %(y=0) + + gn = i + (k - 1) * (mx + 1) + (mx + 1) * (mz + 1) * my; + Sback(m) = gn; %(y=dy) + + L1 = w; + L3 = d; + Sfront(m, 2) = L1 * L3; + Sfront(m, 3:5) = [0, -1, 0]; + Sback(m, 2) = L1 * L3; + Sback(m, 3:5) = [0, 1, 0]; + + m = m + 1; + end + + end + + gammat = [Stop; Sbot; Sright; Sfront; Sback]; % t=0 + gammau = Sleft; % set containg fixed nodes u=0 + gammaMixed = Smixed; % t1=t2=0, u3= U + + fixedDofs = [3 * gammau(:, 1) - 2; 3 * gammau(:, 1) - 1; 3 * gammau(:, 1); 3 * gammaMixed(:, 1)]; + freeDofs = [3 * gammat(:, 1) - 2; 3 * gammat(:, 1) - 1; 3 * gammat(:, 1); 3 * gammaMixed(:, 1) - 2; ... + 3 * gammaMixed(:, 1) - 1]; + + for m = 1:length(fixedDofs) + i = fixedDofs(m); + K(:, i) = 0; + K(i, :) = 0; + K(i, i) = bcwt; + end + + % {freeDofs,fixedDofs} should contain every degree of freedom on boundary + + % any internal Dofs with a force or displacement specified. + if length([fixedDofs; freeDofs]) > length(unique([fixedDofs; freeDofs])) + fprintf('error\n') + pause + end + + fprintf('Cholesky Factorization of K...\n'); %should be symmetric! + tic; + U = chol(K); + L = U'; + toc; + + processForceDisp = 'cantileverBendingForceDisp'; + plotForceDisp = 'cantileverBendingPlot'; + + fprintf('finished FEM\n') + +end diff --git a/src/cantileverBendingForceDisp.m b/src/cantileverBendingForceDisp.m new file mode 100644 index 00000000..60e10734 --- /dev/null +++ b/src/cantileverBendingForceDisp.m @@ -0,0 +1,13 @@ +function [Fsim, Usim, t] = cantileverBendingForceDisp(Fsim, f_bar, f_hat, f_tilda, Usim, u_bar, u_hat, u_tilda, r_hat, ... + gammaMixed, fixedDofs, freeDofs, curstep, simTime) + + f_out = sum(r_hat(3 * gammaMixed(:, 1)) + f_tilda(3 * gammaMixed(:, 1))); + u_out = u_bar; + + Fsim(curstep + 1) = f_out; + Usim(curstep + 1) = u_out; + t(curstep + 1) = simTime; + + fprintf('fend = %d, Ubar = %d, simTime = %d\n', f_out, u_out, simTime); + +end diff --git a/src/cantileverBendingPlot.m b/src/cantileverBendingPlot.m new file mode 100644 index 00000000..47ccaeba --- /dev/null +++ b/src/cantileverBendingPlot.m @@ -0,0 +1,5 @@ +function cantileverBendingPlot(Usim, Fsim, amag, mumag, curstep) + figure(2) + plot(Usim(1:curstep) * amag, -Fsim(1:curstep) * amag^2 * mumag); + drawnow +end diff --git a/src/collideNodesAndSegments.m b/src/collideNodesAndSegments.m new file mode 100644 index 00000000..3d1f2e0c --- /dev/null +++ b/src/collideNodesAndSegments.m @@ -0,0 +1,36 @@ +function [rnnew, linksnew, connectivitynew, linksinconnectnew, fsegnew] = collideNodesAndSegments(docollision, ... + rnnew, linksnew, connectivitynew, linksinconnectnew, fsegnew, rann, MU, NU, a, Ec, mobility, vertices, ... + u_hat, nc, xnodes, D, mx, mz, w, h, d, lmin, CUDA_flag, Bcoeff, curstep) + + if (docollision) + + % Collision detection and handling + colliding_segments = 1; + + while colliding_segments == 1 + [colliding_segments, n1s1, n2s1, n1s2, n2s2, floop, s1, s2, segpair] = CollisionCheckerMex(rnnew(:, 1), rnnew(:, 2), rnnew(:, 3), rnnew(:, end), ... + rnnew(:, 4), rnnew(:, 5), rnnew(:, 6), linksnew(:, 1), linksnew(:, 2), connectivitynew, rann); + + if colliding_segments == 1%scan and update dislocation structure. + + if floop == 1 + fprintf("Step %d. Unconnected links found. Links %d and %d are colliding.\n", curstep, s1, s2) + elseif floop == 2 + fprintf("Step %d. Links %d and %d colliding by hinge condition.\n", curstep, s1, s2) + end + + if colliding_segments == 1 + [rnnew, linksnew, ~, ~, fsegnew, colliding_segments] = collision(rnnew, linksnew, connectivitynew, linksinconnectnew, fsegnew, rann, MU, NU, a, Ec, mobility, vertices, ... + u_hat, nc, xnodes, D, mx, mz, w, h, d, floop, n1s1, n2s1, n1s2, n2s2, s1, s2, segpair, lmin, CUDA_flag, Bcoeff); + + %removing links with effective zero Burgers vectors + [rnnew, linksnew, connectivitynew, linksinconnectnew, fsegnew] = cleanupsegments(rnnew, linksnew, fsegnew); + end + + end + + end + + end + +end diff --git a/src/collision.m b/src/collision.m index b1b95cd3..56bf78ce 100644 --- a/src/collision.m +++ b/src/collision.m @@ -99,14 +99,10 @@ posvel = rn(n1s2, 1:lrn3) .* (1 - L2) + rn(n2s2, 1:lrn3) .* L2; [rn, links, connectivity, linksinconnect] = splitnode(rn, links, connectivity, linksinconnect, spnode, splitconnection, posvel); mergenode2 = length(rn(:, 1)); - %linknew=length(links(:,1)); - %links(linknew,6:8)=links(s2,6:8); fseg = [fseg; zeros(1, 6)]; end if colliding_segments == 1 - % merge the two colliding nodes - % disp(sprintf('node %d and node %d are colliding by two line collision',mergenode1,mergenode2)) collisionpoint = findcollisionpoint(mergenode1, mergenode2, rn, connectivity, links); rn(mergenode1, 1:lrn2) = [collisionpoint 0 0 0 max(rn(mergenode1, lrn2), rn(mergenode2, lrn2))]; [rn, connectivity, links, linksinconnect, fseg, mergednodeid] = mergenodes(rn, connectivity, links, linksinconnect, fseg, mergenode1, mergenode2, MU, NU, a, Ec); @@ -218,7 +214,6 @@ end %merge the two nodes - % disp(sprintf('node %d and node %d are colliding by hinge condition',mergenode2,mergenode1)) collisionpoint = findcollisionpoint(mergenode1, mergenode2, rn, connectivity, links); rn(mergenode1, 1:lrn2) = [collisionpoint 0 0 0 max(rn(mergenode1, lrn2), rn(mergenode2, lrn2))]; [rn, connectivity, links, linksinconnect, fseg, mergednodeid] = mergenodes(rn, connectivity, links, linksinconnect, fseg, mergenode1, mergenode2, MU, NU, a, Ec); diff --git a/src/compileCode.m b/src/compileCode.m index f53c09ed..4589ef4a 100644 --- a/src/compileCode.m +++ b/src/compileCode.m @@ -35,7 +35,7 @@ file = dir(name); if ~isfile(name) ||~isfile(file.name) && days(file.date - datetime('now')) > 30 - mex -v COPTIMFLAGS = "-o3 -oy -DNDEBUG -use_fast_math" SegSegForcesMex.c + mex -v COPTIMFLAGS="-o3 -oy -DNDEBUG -use_fast_math" SegSegForcesMex.c end % Stress tue to segments (field point stress). @@ -43,7 +43,7 @@ file = dir(name); if ~isfile(name) ||~isfile(file.name) && days(file.date - datetime('now')) > 30 - mex -v COPTIMFLAGS = "-o3 -oy -DNDEBUG -use_fast_math" StressDueToSegsMex.c + mex -v COPTIMFLAGS="-o3 -oy -DNDEBUG -use_fast_math" StressDueToSegsMex.c end % Stress tue to segments (field point stress). @@ -51,7 +51,7 @@ file = dir(name); if ~isfile(name) ||~isfile(file.name) && days(file.date - datetime('now')) > 30 - mex -v COPTIMFLAGS = "-o3 -oy -DNDEBUG -use_fast_math" MinDistCalcMex.c + mex -v COPTIMFLAGS="-o3 -oy -DNDEBUG -use_fast_math" MinDistCalcMex.c end % Collision checker. @@ -59,7 +59,7 @@ file = dir(name); if ~isfile(name) ||~isfile(file.name) && days(file.date - datetime('now')) > 30 - mex -v COPTIMFLAGS = "-o3 -oy -DNDEBUG -use_fast_math" CollisionCheckerMex.c + mex -v COPTIMFLAGS="-o3 -oy -DNDEBUG -use_fast_math" CollisionCheckerMex.c end % Analytic surface tractions. @@ -67,7 +67,7 @@ file = dir(name); if ~isfile(name) ||~isfile(file.name) && days(file.date - datetime('now')) > 30 - mex -v COPTIMFLAGS = "-o3 -oy -DNDEBUG -use_fast_math" NodalSurfaceForceLinearRectangleMex.c + mex -v COPTIMFLAGS="-o3 -oy -DNDEBUG -use_fast_math" NodalSurfaceForceLinearRectangleMex.c end %% Cuda codes. @@ -80,7 +80,7 @@ file = dir(name); if ~isfile(name) ||~isfile(file.name) && days(file.date - datetime('now')) > 30 - mexcuda -v COMPFLAGS = "-Xptxas" COPTIMFLAGS = "-o3 -oy -use_fast_math -DNDEBUG" NodalSurfaceForceLinearRectangleMexCUDA.cu + mexcuda -v COMPFLAGS="-Xptxas" COPTIMFLAGS = "-o3 -oy -use_fast_math -DNDEBUG" NodalSurfaceForceLinearRectangleMexCUDA.cu end % SegSeg forces CUDA. @@ -93,7 +93,7 @@ catch CUDA_flag = false; - disp("No CUDA compiler found. Using serial implementation. CUDA_flag set to false.") + sprintf('No CUDA compiler found. Using serial implementation. CUDA_flag set to false.\n') end end diff --git a/src/consistencycheck.m b/src/consistencycheck.m index 9e586ecd..cc6b800a 100644 --- a/src/consistencycheck.m +++ b/src/consistencycheck.m @@ -37,7 +37,7 @@ function consistencycheck(rn, links, connectivity, linksinconnect) numNbrs = connectivity(i, 1); if (sum(connectivity(i, 2 * (numNbrs + 1):end) ~= 0)) - disp('inconsistent connectivity list'); + fprintf('inconsistent connectivity list\n'); fprintf('%d\n', i) connectivity(i, :) pause(0.01) @@ -69,11 +69,6 @@ function consistencycheck(rn, links, connectivity, linksinconnect) end - %if(sum(sum(connectivity==length(links(:,1))))~=2) - % disp(sprintf('arm %d has %d ends',length(links(:,1)),sum(sum(connectivity==length(links(:,1)))))) - % pause(0.01) - %end - %item 4 % a node cannot be connected to another node twice for i = 1:nnodes @@ -175,7 +170,7 @@ function consistencycheck(rn, links, connectivity, linksinconnect) pause(0.01) end - disp('Consistencycheck : Done!'); + fprintf('Consistencycheck : Done!\n'); end end diff --git a/src/displacementControl.m b/src/displacementControl.m new file mode 100644 index 00000000..46e31481 --- /dev/null +++ b/src/displacementControl.m @@ -0,0 +1,6 @@ +function [u, u_bar, f, f_bar, calculateR_hat] = displacementControl(u, u_dot, sign_u_dot, f, f_dot, sign_f_dot, simTime, gamma_mixed) + f_bar = 0; + u_bar = u_dot * simTime; + u(3 * gamma_mixed(:, 1)) = sign_u_dot * u_bar; + calculateR_hat = true; +end diff --git a/src/drndt.m b/src/drndt.m index fa7f6d36..2d772103 100644 --- a/src/drndt.m +++ b/src/drndt.m @@ -46,7 +46,7 @@ linvec = rn(p, 1:3) - realconnodes; % Segments should not have zero length if norm(linvec) < eps - disp('Remeshing error detected. See line 48 of drndt.m') + fprintf('Remeshing error detected. See line 48 of drndt.m\n') pause end @@ -69,7 +69,7 @@ surfplanes = normals(abs(dotprods) > tol, :); % If no surface normals can be detected then there is an error if isempty(surfplanes) - disp('Weird surface node detected. See line 67 of drndt.m') + fprintf('Weird surface node detected. See line 67 of drndt.m\n') pause end @@ -78,7 +78,7 @@ lines(:, 1:3) = lines(:, 1:3) / norm(lines(:, 1:3)); % If the surface plane is a viable slip plane if any(any(isnan(lines))) - disp('Check surface remeshing re line 75 of drndt.m') + fprintf('Check surface remeshing re line 75 of drndt.m\n') continue end diff --git a/src/finiteElement3D.m b/src/finiteElement3D.m index 760f0063..54aa20e4 100644 --- a/src/finiteElement3D.m +++ b/src/finiteElement3D.m @@ -1,642 +1,358 @@ -function [vertices, B, xnodes, mno, nc, n, D, kg, K, L, U, Sleft, Sright, Stop, Sbot, ... - Sfront, Sback, gammat, gammau, gammaMixed, fixedDofs, freeDofs, ... - w, h, d, my, mz, mel] = finiteElement3D(dx, dy, dz, mx, mu, nu, loading) -%=========================================================================% -% E Tarleton edmund.tarleton@materials.ox.ac.uk -% 3D FEM code using linear 8 node element with 8 integration pts (2x2x2) -% per element -% -% 4. ----- .3 -% |\ |\ -% | \ | \ -% 1. -\---- .2 \ -% \ \ \ \ -% \ 8. ----\- .7 -% \ | \ | -% \| \| -% 5. ----- .6 -% -% -% rectangulare domain. -% (y going in to the page) note this is rotated about x axis w.r.t. local -% (s1,s2,s3) system. -% ------------------------------------------------- -% -% ^z (mx,my) -% | -% | -% |------>x----------------------------------------- -%=========================================================================% - -disp('Constructing stiffness matrix K and precomputing L,U decompositions. Please wait.'); - -% Simulation domain vertices. Required for surface remeshing. -vertices = [0, 0, 0; ... - dx, 0, 0; ... - 0, dy, 0; ... - dx, dy, 0; ... - 0, 0, dz; ... - dx, 0, dz; ... - 0, dy, dz; ... - dx, dy, dz]; -% not that this code uses a constant element size in base and beam: (w,h,d) -% also gammau is the left surface (eg baseLength=0) -% loading = 1; - -w = dx / mx; % elements width - -my = round(mx * dy / dx); % # elements in y direction -my = max(my, 1); -h = dy / my; % element height - -mz = round(mx * dz / dx); % elements in z direction -mz = max(mz, 1); -d = dz / mz; % element depth - -mel = mx * my * mz; -mno = (mx + 1) * (my + 1) * (mz + 1); - -ey = mu * (2 * (1 + nu)); -la = nu * ey / ((1 + nu) * (1 - 2 * nu)); - -D = zeros(6, 6); - -for i = 1:3 - D(i, i) = la + 2 * mu; -end - -for i = 4:6 - D(i, i) = mu; -end - -D(1, 2) = la; -D(1, 3) = la; -D(2, 3) = la; - -% plane stress -% D(1,1) = ey/(1-nu^2); -% D(1,2) = ey*nu/(1-nu^2); -% D(2,2) = D(1,1); -% D(3,3) = ey/2/(1+nu); -% -D(2, 1) = D(1, 2); -D(3, 1) = D(1, 3); -D(3, 2) = D(2, 3); - -% -% ^s2 -% | -% | -% |------>s1 -% -%(s3 out of page) -zv = 1 / sqrt(3); -z = zeros(8, 3); -z(1, 1:3) = [-zv, -zv, -zv]; -z(2, 1:3) = [zv, -zv, -zv]; -z(3, 1:3) = [zv, zv, -zv]; -z(4, 1:3) = [-zv, zv, -zv]; -z(5, 1:3) = [-zv, -zv, zv]; -z(6, 1:3) = [zv, -zv, zv]; -z(7, 1:3) = [zv, zv, zv]; -z(8, 1:3) = [-zv, zv, zv]; - -xnodes = zeros(mno, 3); %global nodal coordinates gn - -%back face y = dy, C = (mx+1)*(mz+1)*my -%1+mz*(mx+1)+C ... (mx+1)*(mz+1)+C -% . . . -% . . . -% 1+(mx+1)+C 2+(mx+1)+C ... 2*(mx+1)+C -% 1+C 2+C ... mx+1 + C - -% front face y = 0 -% 1+mz*(mx+1) ... (mx+1)*(mz+1) -% . . . -% . . . -% 1+(mx+1) 2+(mx+1) ... 2*(mx+1) -% 1 2 ... mx+1 - -for k = 1:mz + 1 - - for j = 1:my + 1% nodes in x direction - - for i = 1:mx + 1 - gn = i + (k - 1) * (mx + 1) + (j - 1) * (mx + 1) * (mz + 1); %global node # - xnodes(gn, 1) = (i - 1) * w; - xnodes(gn, 2) = (j - 1) * h; - xnodes(gn, 3) = (k - 1) * d; - end - - end - -end - -nc = zeros(mel, 4); %element connectivity -% 4. ----- .3 -% �\ �\ -% � \ � \ -% 1. -\---- .2 \ -% \ \ \ \ -% \ 8. ----\- .7 -% \ � \ � -% \� \� -% 5. ----- .6 - -for k = 1:mz - - for j = 1:my% i = row index, j = column index - - for i = 1:mx%global node #(element #,local node #) - ge = i + (k - 1) * (mx) + (j - 1) * mx * mz; % element number - nc(ge, 1) = i + (k - 1) * (mx + 1) + (mx + 1) * (mz + 1) * j; - nc(ge, 2) = nc(ge, 1) + 1; - nc(ge, 4) = i + k * (mx + 1) + (mx + 1) * (mz + 1) * j; - nc(ge, 3) = nc(ge, 4) + 1; - nc(ge, 5) = i + (k - 1) * (mx + 1) + (mx + 1) * (mz + 1) * (j - 1); - nc(ge, 6) = nc(ge, 5) + 1; - nc(ge, 8) = i + k * (mx + 1) + (mx + 1) * (mz + 1) * (j - 1); - nc(ge, 7) = nc(ge, 8) + 1; - end - +function [vertices, B, xnodes, mno, nc, n, D, kg, w, h, d, my, mz, mel] = finiteElement3D(dx, dy, dz, mx, mu, nu) + %=========================================================================% + % E Tarleton edmund.tarleton@materials.ox.ac.uk + % 3D FEM code using linear 8 node element with 8 integration pts (2x2x2) + % per element + % + % 4. ----- .3 + % |\ |\ + % | \ | \ + % 1. -\---- .2 \ + % \ \ \ \ + % \ 8. ----\- .7 + % \ | \ | + % \| \| + % 5. ----- .6 + % + % + % rectangulare domain. + % (y going in to the page) note this is rotated about x axis w.r.t. local + % (s1,s2,s3) system. + % ------------------------------------------------- + % + % ^z (mx,my) + % | + % | + % |------>x----------------------------------------- + %=========================================================================% + + fprintf('Constructing stiffness matrix K and precomputing L,U decompositions. Please wait.\n'); + + % Simulation domain vertices. Required for surface remeshing. + vertices = [0, 0, 0; ... + dx, 0, 0; ... + 0, dy, 0; ... + dx, dy, 0; ... + 0, 0, dz; ... + dx, 0, dz; ... + 0, dy, dz; ... + dx, dy, dz]; + % not that this code uses a constant element size in base and beam: (w,h,d) + % also gammau is the left surface (eg baseLength=0) + % loading = 1; + + w = dx / mx; % elements width + + my = round(mx * dy / dx); % # elements in y direction + my = max(my, 1); + h = dy / my; % element height + + mz = round(mx * dz / dx); % elements in z direction + mz = max(mz, 1); + d = dz / mz; % element depth + + mel = mx * my * mz; + mno = (mx + 1) * (my + 1) * (mz + 1); + + ey = mu * (2 * (1 + nu)); + la = nu * ey / ((1 + nu) * (1 - 2 * nu)); + + D = zeros(6, 6); + + for i = 1:3 + D(i, i) = la + 2 * mu; end -end - -% figure(1);clf;hold on;view(3) -% xlabel('x');ylabel('y');zlabel('z') -% for p =1:mel -% % plot3(x(:,1),x(:,2),x(:,3),'.') % plot nodes -% % plot elements -% plot3(xnodes(nc(p,[1:4,1]),1),xnodes(nc(p,[1:4,1]),2),xnodes(nc(p,[1:4,1]),3),'-') -% plot3(xnodes(nc(p,[5:8,5]),1),xnodes(nc(p,[5:8,5]),2),xnodes(nc(p,[5:8,5]),3),'-') -% plot3(xnodes(nc(p,[1,5]),1),xnodes(nc(p,[1,5]),2),xnodes(nc(p,[1,5]),3),'-') % -% plot3(xnodes(nc(p,[2,6]),1),xnodes(nc(p,[2,6]),2),xnodes(nc(p,[2,6]),3),'-') % -% plot3(xnodes(nc(p,[3,7]),1),xnodes(nc(p,[3,7]),2),xnodes(nc(p,[3,7]),3),'-') % -% plot3(xnodes(nc(p,[4,8]),1),xnodes(nc(p,[4,8]),2),xnodes(nc(p,[4,8]),3),'-') % -% end -% axis('equal') -% hold off - -n = zeros(8, 8); -% n(q,a) is shape function Na(s1,s2,s3) evaluated at integration point q -for q = 1:8 - n(q, 1) = 1/8 * (1 - z(q, 1)) * (1 - z(q, 2)) * (1 - z(q, 3)); - n(q, 2) = 1/8 * (1 + z(q, 1)) * (1 - z(q, 2)) * (1 - z(q, 3)); - n(q, 3) = 1/8 * (1 + z(q, 1)) * (1 + z(q, 2)) * (1 - z(q, 3)); - n(q, 4) = 1/8 * (1 - z(q, 1)) * (1 + z(q, 2)) * (1 - z(q, 3)); - n(q, 5) = 1/8 * (1 - z(q, 1)) * (1 - z(q, 2)) * (1 + z(q, 3)); - n(q, 6) = 1/8 * (1 + z(q, 1)) * (1 - z(q, 2)) * (1 + z(q, 3)); - n(q, 7) = 1/8 * (1 + z(q, 1)) * (1 + z(q, 2)) * (1 + z(q, 3)); - n(q, 8) = 1/8 * (1 - z(q, 1)) * (1 + z(q, 2)) * (1 + z(q, 3)); -end - -ns = zeros(8, 8, 3); -% derivative of shape function Na(s1,s2,s3) w.r.t. sj evaluated at -%integration point q ns(q,a,j) = (dNa/dsj)s=zq -for q = 1:8 - ns(q, 1, 1) = -1/8 * (1 - z(q, 2)) * (1 - z(q, 3)); - ns(q, 1, 2) = -1/8 * (1 - z(q, 1)) * (1 - z(q, 3)); - ns(q, 1, 3) = -1/8 * (1 - z(q, 1)) * (1 - z(q, 2)); - ns(q, 2, 1) = 1/8 * (1 - z(q, 2)) * (1 - z(q, 3)); - ns(q, 2, 2) = -1/8 * (1 + z(q, 1)) * (1 - z(q, 3)); - ns(q, 2, 3) = -1/8 * (1 + z(q, 1)) * (1 - z(q, 2)); - ns(q, 3, 1) = 1/8 * (1 + z(q, 2)) * (1 - z(q, 3)); - ns(q, 3, 2) = 1/8 * (1 + z(q, 1)) * (1 - z(q, 3)); - ns(q, 3, 3) = -1/8 * (1 + z(q, 1)) * (1 + z(q, 2)); - ns(q, 4, 1) = -1/8 * (1 + z(q, 2)) * (1 - z(q, 3)); - ns(q, 4, 2) = 1/8 * (1 - z(q, 1)) * (1 - z(q, 3)); - ns(q, 4, 3) = -1/8 * (1 - z(q, 1)) * (1 + z(q, 2)); - - ns(q, 5, 1) = -1/8 * (1 - z(q, 2)) * (1 + z(q, 3)); - ns(q, 5, 2) = -1/8 * (1 - z(q, 1)) * (1 + z(q, 3)); - ns(q, 5, 3) = 1/8 * (1 - z(q, 1)) * (1 - z(q, 2)); - ns(q, 6, 1) = 1/8 * (1 - z(q, 2)) * (1 + z(q, 3)); - ns(q, 6, 2) = -1/8 * (1 + z(q, 1)) * (1 + z(q, 3)); - ns(q, 6, 3) = 1/8 * (1 + z(q, 1)) * (1 - z(q, 2)); - ns(q, 7, 1) = 1/8 * (1 + z(q, 2)) * (1 + z(q, 3)); - ns(q, 7, 2) = 1/8 * (1 + z(q, 1)) * (1 + z(q, 3)); - ns(q, 7, 3) = 1/8 * (1 + z(q, 1)) * (1 + z(q, 2)); - ns(q, 8, 1) = -1/8 * (1 + z(q, 2)) * (1 + z(q, 3)); - ns(q, 8, 2) = 1/8 * (1 - z(q, 1)) * (1 + z(q, 3)); - ns(q, 8, 3) = 1/8 * (1 - z(q, 1)) * (1 + z(q, 2)); -end - -pm1 = [-1 1 1 -1 -1 1 1 -1]; -pm2 = [-1 -1 1 1 -1 -1 1 1]; -pm3 = [-1 -1 -1 -1 1 1 1 1]; - -% pm1 =[-1 1 1 -1 -1 1 1 -1] -% pm2 =[-1 -1 1 1 -1 -1 1 1] -% pm3 =[-1 -1 -1 -1 1 1 1 1] -dNds = zeros(8, 8, 3); -% Na(s1,s2,s3) = 1/8 *(1+pm1(a)s1)(1+pm2(a)s2)(1+pm3(a)s3) -for q = 1:8 - - for a = 1:8 - dNds(q, a, 1) = 1/8 * pm1(a) * (1 + pm2(a) * z(q, 2)) * (1 + pm3(a) * z(q, 3)); - dNds(q, a, 2) = 1/8 * (1 + pm1(a) * z(q, 1)) * pm2(a) * (1 + pm3(a) * z(q, 3)); - dNds(q, a, 3) = 1/8 * (1 + pm1(a) * z(q, 1)) * (1 + pm2(a) * z(q, 2)) * pm3(a); + for i = 4:6 + D(i, i) = mu; end -end - -if any(dNds ~= ns) - fprintf('error\n') - pause -end - -J = zeros(3, 3, mel, 8); % 3Dx3D, mel elements, 8 quad pts/element -detJ = zeros(mel, 8); % det(J) at mel elements, 9 quad points/element -nx = zeros(mel, 8, 8, 3); % derivative of shape functions w.r.t global x,y -B = zeros(6, 24, mel, 8); % (# strain components, # dof/element, # elements, int pts/element) + D(1, 2) = la; + D(1, 3) = la; + D(2, 3) = la; -for p = 1:mel% all elements - - for q = 1:8% integration points per element - - for i = 1:3% DOF + % plane stress + % D(1,1) = ey/(1-nu^2); + % D(1,2) = ey*nu/(1-nu^2); + % D(2,2) = D(1,1); + % D(3,3) = ey/2/(1+nu); + % + D(2, 1) = D(1, 2); + D(3, 1) = D(1, 3); + D(3, 2) = D(2, 3); - for j = 1:3% DOF - J(i, j, p, q) = ns(q, 1:8, j) * xnodes(nc(p, 1:8), i); - % implied sum over a: local shape function number - % sum over a of dNa(s1,s2,s3)/dsj at S=z(q) *xi(local node a of element p) - %Jij= dxi/dsj evaluated at element p integration point q + % + % ^s2 + % | + % | + % |------>s1 + % + %(s3 out of page) + zv = 1 / sqrt(3); + z = zeros(8, 3); + z(1, 1:3) = [-zv, -zv, -zv]; + z(2, 1:3) = [zv, -zv, -zv]; + z(3, 1:3) = [zv, zv, -zv]; + z(4, 1:3) = [-zv, zv, -zv]; + z(5, 1:3) = [-zv, -zv, zv]; + z(6, 1:3) = [zv, -zv, zv]; + z(7, 1:3) = [zv, zv, zv]; + z(8, 1:3) = [-zv, zv, zv]; + + xnodes = zeros(mno, 3); %global nodal coordinates gn + + %back face y = dy, C = (mx+1)*(mz+1)*my + %1+mz*(mx+1)+C ... (mx+1)*(mz+1)+C + % . . . + % . . . + % 1+(mx+1)+C 2+(mx+1)+C ... 2*(mx+1)+C + % 1+C 2+C ... mx+1 + C + + % front face y = 0 + % 1+mz*(mx+1) ... (mx+1)*(mz+1) + % . . . + % . . . + % 1+(mx+1) 2+(mx+1) ... 2*(mx+1) + % 1 2 ... mx+1 + + for k = 1:mz + 1 + + for j = 1:my + 1% nodes in x direction + + for i = 1:mx + 1 + gn = i + (k - 1) * (mx + 1) + (j - 1) * (mx + 1) * (mz + 1); %global node # + xnodes(gn, 1) = (i - 1) * w; + xnodes(gn, 2) = (j - 1) * h; + xnodes(gn, 3) = (k - 1) * d; end end - detJ(p, q) = det(J(:, :, p, q)); % det(J) evaluated at element p int point q - - invJ = inv(J(:, :, p, q)); % invJ_ij = dsi/dxj - - for a = 1:8 - - for j = 1:3 - - for i = 1:3 - nx(p, q, a, j) = nx(p, q, a, j) + ns(q, a, i) * invJ(i, j); - end + end + nc = zeros(mel, 4); %element connectivity + % 4. ----- .3 + % �\ �\ + % � \ � \ + % 1. -\---- .2 \ + % \ \ \ \ + % \ 8. ----\- .7 + % \ � \ � + % \� \� + % 5. ----- .6 + + for k = 1:mz + + for j = 1:my% i = row index, j = column index + + for i = 1:mx%global node #(element #,local node #) + ge = i + (k - 1) * (mx) + (j - 1) * mx * mz; % element number + nc(ge, 1) = i + (k - 1) * (mx + 1) + (mx + 1) * (mz + 1) * j; + nc(ge, 2) = nc(ge, 1) + 1; + nc(ge, 4) = i + k * (mx + 1) + (mx + 1) * (mz + 1) * j; + nc(ge, 3) = nc(ge, 4) + 1; + nc(ge, 5) = i + (k - 1) * (mx + 1) + (mx + 1) * (mz + 1) * (j - 1); + nc(ge, 6) = nc(ge, 5) + 1; + nc(ge, 8) = i + k * (mx + 1) + (mx + 1) * (mz + 1) * (j - 1); + nc(ge, 7) = nc(ge, 8) + 1; end - B(1, (a - 1) * 3 + 1, p, q) = nx(p, q, a, 1); - B(1, (a - 1) * 3 + 2, p, q) = 0; - B(1, (a - 1) * 3 + 3, p, q) = 0; - - B(2, (a - 1) * 3 + 1, p, q) = 0; - B(2, (a - 1) * 3 + 2, p, q) = nx(p, q, a, 2); - B(2, (a - 1) * 3 + 3, p, q) = 0; - - B(3, (a - 1) * 3 + 1, p, q) = 0; - B(3, (a - 1) * 3 + 2, p, q) = 0; - B(3, (a - 1) * 3 + 3, p, q) = nx(p, q, a, 3); - - B(4, (a - 1) * 3 + 1, p, q) = nx(p, q, a, 2); - B(4, (a - 1) * 3 + 2, p, q) = nx(p, q, a, 1); - B(4, (a - 1) * 3 + 3, p, q) = 0; - - B(5, (a - 1) * 3 + 1, p, q) = nx(p, q, a, 3); - B(5, (a - 1) * 3 + 2, p, q) = 0; - B(5, (a - 1) * 3 + 3, p, q) = nx(p, q, a, 1); - - B(6, (a - 1) * 3 + 1, p, q) = 0; - B(6, (a - 1) * 3 + 2, p, q) = nx(p, q, a, 3); - B(6, (a - 1) * 3 + 3, p, q) = nx(p, q, a, 2); - end end -end - -disp('local K...'); -ke = zeros(24, 24, mel); %local stiffness matrix - -for p = 1:mel%all elements + % figure(1);clf;hold on;view(3) + % xlabel('x');ylabel('y');zlabel('z') + % for p =1:mel + % % plot3(x(:,1),x(:,2),x(:,3),'.') % plot nodes + % % plot elements + % plot3(xnodes(nc(p,[1:4,1]),1),xnodes(nc(p,[1:4,1]),2),xnodes(nc(p,[1:4,1]),3),'-') + % plot3(xnodes(nc(p,[5:8,5]),1),xnodes(nc(p,[5:8,5]),2),xnodes(nc(p,[5:8,5]),3),'-') + % plot3(xnodes(nc(p,[1,5]),1),xnodes(nc(p,[1,5]),2),xnodes(nc(p,[1,5]),3),'-') % + % plot3(xnodes(nc(p,[2,6]),1),xnodes(nc(p,[2,6]),2),xnodes(nc(p,[2,6]),3),'-') % + % plot3(xnodes(nc(p,[3,7]),1),xnodes(nc(p,[3,7]),2),xnodes(nc(p,[3,7]),3),'-') % + % plot3(xnodes(nc(p,[4,8]),1),xnodes(nc(p,[4,8]),2),xnodes(nc(p,[4,8]),3),'-') % + % end + % axis('equal') + % hold off + + n = zeros(8, 8); + % n(q,a) is shape function Na(s1,s2,s3) evaluated at integration point q + for q = 1:8 + n(q, 1) = 1/8 * (1 - z(q, 1)) * (1 - z(q, 2)) * (1 - z(q, 3)); + n(q, 2) = 1/8 * (1 + z(q, 1)) * (1 - z(q, 2)) * (1 - z(q, 3)); + n(q, 3) = 1/8 * (1 + z(q, 1)) * (1 + z(q, 2)) * (1 - z(q, 3)); + n(q, 4) = 1/8 * (1 - z(q, 1)) * (1 + z(q, 2)) * (1 - z(q, 3)); + n(q, 5) = 1/8 * (1 - z(q, 1)) * (1 - z(q, 2)) * (1 + z(q, 3)); + n(q, 6) = 1/8 * (1 + z(q, 1)) * (1 - z(q, 2)) * (1 + z(q, 3)); + n(q, 7) = 1/8 * (1 + z(q, 1)) * (1 + z(q, 2)) * (1 + z(q, 3)); + n(q, 8) = 1/8 * (1 - z(q, 1)) * (1 + z(q, 2)) * (1 + z(q, 3)); + end - for q = 1:8% int points per element - ke(:, :, p) = ke(:, :, p) + B(:, :, p, q)' * D * B(:, :, p, q) * detJ(p, q); + ns = zeros(8, 8, 3); + % derivative of shape function Na(s1,s2,s3) w.r.t. sj evaluated at + %integration point q ns(q,a,j) = (dNa/dsj)s=zq + for q = 1:8 + ns(q, 1, 1) = -1/8 * (1 - z(q, 2)) * (1 - z(q, 3)); + ns(q, 1, 2) = -1/8 * (1 - z(q, 1)) * (1 - z(q, 3)); + ns(q, 1, 3) = -1/8 * (1 - z(q, 1)) * (1 - z(q, 2)); + ns(q, 2, 1) = 1/8 * (1 - z(q, 2)) * (1 - z(q, 3)); + ns(q, 2, 2) = -1/8 * (1 + z(q, 1)) * (1 - z(q, 3)); + ns(q, 2, 3) = -1/8 * (1 + z(q, 1)) * (1 - z(q, 2)); + ns(q, 3, 1) = 1/8 * (1 + z(q, 2)) * (1 - z(q, 3)); + ns(q, 3, 2) = 1/8 * (1 + z(q, 1)) * (1 - z(q, 3)); + ns(q, 3, 3) = -1/8 * (1 + z(q, 1)) * (1 + z(q, 2)); + ns(q, 4, 1) = -1/8 * (1 + z(q, 2)) * (1 - z(q, 3)); + ns(q, 4, 2) = 1/8 * (1 - z(q, 1)) * (1 - z(q, 3)); + ns(q, 4, 3) = -1/8 * (1 - z(q, 1)) * (1 + z(q, 2)); + + ns(q, 5, 1) = -1/8 * (1 - z(q, 2)) * (1 + z(q, 3)); + ns(q, 5, 2) = -1/8 * (1 - z(q, 1)) * (1 + z(q, 3)); + ns(q, 5, 3) = 1/8 * (1 - z(q, 1)) * (1 - z(q, 2)); + ns(q, 6, 1) = 1/8 * (1 - z(q, 2)) * (1 + z(q, 3)); + ns(q, 6, 2) = -1/8 * (1 + z(q, 1)) * (1 + z(q, 3)); + ns(q, 6, 3) = 1/8 * (1 + z(q, 1)) * (1 - z(q, 2)); + ns(q, 7, 1) = 1/8 * (1 + z(q, 2)) * (1 + z(q, 3)); + ns(q, 7, 2) = 1/8 * (1 + z(q, 1)) * (1 + z(q, 3)); + ns(q, 7, 3) = 1/8 * (1 + z(q, 1)) * (1 + z(q, 2)); + ns(q, 8, 1) = -1/8 * (1 + z(q, 2)) * (1 + z(q, 3)); + ns(q, 8, 2) = 1/8 * (1 - z(q, 1)) * (1 + z(q, 3)); + ns(q, 8, 3) = 1/8 * (1 - z(q, 1)) * (1 + z(q, 2)); end -end + pm1 = [-1 1 1 -1 -1 1 1 -1]; + pm2 = [-1 -1 1 1 -1 -1 1 1]; + pm3 = [-1 -1 -1 -1 1 1 1 1]; -% ensure ke is symmetric eg remove any very small entries due to numerical -% error. -disp('global K...'); - -% kg = sparse(mno*3,mno*3); -% tic -% a =1:8; -% b =1:8; -% for p =1:mel -% % disp(['assembly ', num2str(100*p/mel), ' % complete']) -% gna=nc(p,a); -% gnb=nc(p,b); -% for i =1:3 -% for j=1:3 -% kg(3*(gna-1)+i,3*(gnb-1)+j)= kg(3*(gna-1)+i,3*(gnb-1)+j)+ke(3*(a-1)+i,3*(b-1)+j,p); -% end -% end -% end -% toc - -%% kg old -% % kg = sparse(mno*3,mno*3); -% % tic; -% % a =1:8; -% % % b =1:8; -% % for p =1:mel -% % percentage = 100*p/mel; -% % if mod(percentage,1)==0 -% % fprintf('Assembly %d percent complete \n',100*p/mel); -% % end -% % gn=nc(p,a); -% % % gnb=nc(p,b); -% % dof(1:24)=[3*(gn-1)+1,3*(gn-1)+2,3*(gn-1)+3]; -% % % dofb(1:24)=[3*(gnb-1)+1,3*(gnb-1)+2,3*(gnb-1)+3] -% % dofLocal=[3*(a-1)+1,3*(a-1)+2,3*(a-1)+3]; -% % % dofbl=[3*(b-1)+1,3*(b-1)+2,3*(b-1)+3] -% % kg(dof,dof)= kg(dof,dof)+ke(dofLocal,dofLocal,p); -% % -% % end - -%% kg Haiyang -tic -a = 1:8; %local node numbers -dofLocal = [3 * (a - 1) + 1, 3 * (a - 1) + 2, 3 * (a - 1) + 3]; -ntriplets = 3 * mno; -I = zeros(ntriplets, 1); -J = zeros(ntriplets, 1); -X = zeros(ntriplets, 1); -ntriplets = 0; - -for p = 1:mel - gn = nc(p, a); % global node numbers - dof(1:24) = [3 * (gn - 1) + 1, 3 * (gn - 1) + 2, 3 * (gn - 1) + 3]; % global degree of freedom - - for i = 1:24 - - for j = 1:24 - ntriplets = ntriplets + 1; - I(ntriplets) = dof(i); - J(ntriplets) = dof(j); - X(ntriplets) = ke(dofLocal(i), dofLocal(j), p); + % pm1 =[-1 1 1 -1 -1 1 1 -1] + % pm2 =[-1 -1 1 1 -1 -1 1 1] + % pm3 =[-1 -1 -1 -1 1 1 1 1] + dNds = zeros(8, 8, 3); + % Na(s1,s2,s3) = 1/8 *(1+pm1(a)s1)(1+pm2(a)s2)(1+pm3(a)s3) + for q = 1:8 + + for a = 1:8 + dNds(q, a, 1) = 1/8 * pm1(a) * (1 + pm2(a) * z(q, 2)) * (1 + pm3(a) * z(q, 3)); + dNds(q, a, 2) = 1/8 * (1 + pm1(a) * z(q, 1)) * pm2(a) * (1 + pm3(a) * z(q, 3)); + dNds(q, a, 3) = 1/8 * (1 + pm1(a) * z(q, 1)) * (1 + pm2(a) * z(q, 2)) * pm3(a); end end - % K{N}(dof,dof)= K{N}(dof,dof)+Ke(dofLocal,dofLocal,p); %the (full) global stiffness matrix - -end + if any(dNds ~= ns) + fprintf('error\n') + pause + end -kg = sparse(I, J, X, 3 * mno, 3 * mno); %the (full) global stiffness matrix + J = zeros(3, 3, mel, 8); % 3Dx3D, mel elements, 8 quad pts/element + detJ = zeros(mel, 8); % det(J) at mel elements, 9 quad points/element + nx = zeros(mel, 8, 8, 3); % derivative of shape functions w.r.t global x,y + B = zeros(6, 24, mel, 8); % (# strain components, # dof/element, # elements, int pts/element) -toc + for p = 1:mel% all elements -%------------------------------ boundary conditions --------------------- -disp('reformatting K'); -% reformat kg due to applied displacements -%f=zeros(mno*2,1); -K = kg; -bcwt = mean(diag(kg)); %=trace(K)/length(K) -bcwt = full(bcwt); + for q = 1:8% integration points per element -if loading == 1 || loading == 0% cantilever bending - % define empty sets (not used but allows same code as for bending) - % priority for inclusion of shared nodes is in order below - %S = [node #, nodal Area, outward normal] - Smixed = zeros(my + 1, 5); % top right edge (u3=U) first priority + for i = 1:3% DOF - Sleft = zeros((my + 1) * (mz + 1), 5); % second priority - Sright = zeros((my + 1) * mz, 3); + for j = 1:3% DOF + J(i, j, p, q) = ns(q, 1:8, j) * xnodes(nc(p, 1:8), i); + % implied sum over a: local shape function number + % sum over a of dNa(s1,s2,s3)/dsj at S=z(q) *xi(local node a of element p) + %Jij= dxi/dsj evaluated at element p integration point q + end - Stop = zeros((mx - 1) * (my + 1), 5); % third priority - Sbot = zeros((mx - 1) * (my + 1), 5); + end - Sfront = zeros((mz - 1) * (mx - 1), 5); % fourth priority - Sback = zeros((mz - 1) * (mx - 1), 5); + detJ(p, q) = det(J(:, :, p, q)); % det(J) evaluated at element p int point q - m = 1; + invJ = inv(J(:, :, p, q)); % invJ_ij = dsi/dxj - for j = 1:my + 1 + for a = 1:8 - for k = 1:mz + 1 - % left surface of beam (u=0) - gn = 1 + (k - 1) * (mx + 1) + (mx + 1) * (mz + 1) * (j - 1); - Sleft(m, 1) = gn; + for j = 1:3 - if k == 1 || k == mz + 1 - L3 = 0.5 * d; - else - L3 = d; - end + for i = 1:3 + nx(p, q, a, j) = nx(p, q, a, j) + ns(q, a, i) * invJ(i, j); + end - if j == 1 || j == my + 1 - L2 = 0.5 * h; - else - L2 = h; - end + end - Sleft(m, 2) = L2 * L3; - Sleft(m, 3:5) = [-1, 0, 0]; - m = m + 1; - end + B(1, (a - 1) * 3 + 1, p, q) = nx(p, q, a, 1); + B(1, (a - 1) * 3 + 2, p, q) = 0; + B(1, (a - 1) * 3 + 3, p, q) = 0; - end + B(2, (a - 1) * 3 + 1, p, q) = 0; + B(2, (a - 1) * 3 + 2, p, q) = nx(p, q, a, 2); + B(2, (a - 1) * 3 + 3, p, q) = 0; - m = 1; + B(3, (a - 1) * 3 + 1, p, q) = 0; + B(3, (a - 1) * 3 + 2, p, q) = 0; + B(3, (a - 1) * 3 + 3, p, q) = nx(p, q, a, 3); - for j = 1:my + 1 + B(4, (a - 1) * 3 + 1, p, q) = nx(p, q, a, 2); + B(4, (a - 1) * 3 + 2, p, q) = nx(p, q, a, 1); + B(4, (a - 1) * 3 + 3, p, q) = 0; - for k = 1:mz - % right surface of beam (t=0) - gn = k * (mx + 1) + (mx + 1) * (mz + 1) * (j - 1); - Sright(m, 1) = gn; + B(5, (a - 1) * 3 + 1, p, q) = nx(p, q, a, 3); + B(5, (a - 1) * 3 + 2, p, q) = 0; + B(5, (a - 1) * 3 + 3, p, q) = nx(p, q, a, 1); - if k == 1 - L3 = 0.5 * d; - else - L3 = d; - end + B(6, (a - 1) * 3 + 1, p, q) = 0; + B(6, (a - 1) * 3 + 2, p, q) = nx(p, q, a, 3); + B(6, (a - 1) * 3 + 3, p, q) = nx(p, q, a, 2); - if j == 1 || j == my + 1 - L2 = 0.5 * h; - else - L2 = h; end - Sright(m, 2) = L2 * L3; - Sright(m, 3:5) = [1, 0, 0]; - m = m + 1; end end - m = 1; + fprintf('local K...\n'); + ke = zeros(24, 24, mel); %local stiffness matrix - for j = 1:my + 1 - % top right loaded edge (t1=0, u2=-U) mixed surface - gn = (mx + 1) * (mz + 1) * j; - Smixed(m, 1) = gn; + for p = 1:mel%all elements - if j == 1 || j == my + 1 - L2 = 0.5 * h; - else - L2 = h; + for q = 1:8% int points per element + ke(:, :, p) = ke(:, :, p) + B(:, :, p, q)' * D * B(:, :, p, q) * detJ(p, q); end - L3 = 0.5 * d; - Smixed(m, 2) = L2 * L3; - Smixed(m, 3:5) = [1, 0, 0]; - m = m + 1; end - m = 1; - - for j = 1:my + 1 - - for i = 2:mx - % bottom surface of beam (t=0) - gn = i + (mx + 1) * (mz + 1) * (j - 1); - Sbot(m, 1) = gn; - % top surface of beam (t=0) - gn = i + (mx + 1) * mz + (mx + 1) * (mz + 1) * (j - 1); - Stop(m, 1) = gn; - - L1 = w; - - if j == 1 || j == my + 1 - L2 = 0.5 * h; - else - L2 = h; + % ensure ke is symmetric eg remove any very small entries due to numerical + % error. + fprintf('global K...\n'); + + %% kg Haiyang + tic + a = 1:8; %local node numbers + dofLocal = [3 * (a - 1) + 1, 3 * (a - 1) + 2, 3 * (a - 1) + 3]; + ntriplets = 3 * mno; + I = zeros(ntriplets, 1); + J = zeros(ntriplets, 1); + X = zeros(ntriplets, 1); + ntriplets = 0; + + for p = 1:mel + gn = nc(p, a); % global node numbers + dof(1:24) = [3 * (gn - 1) + 1, 3 * (gn - 1) + 2, 3 * (gn - 1) + 3]; % global degree of freedom + + for i = 1:24 + + for j = 1:24 + ntriplets = ntriplets + 1; + I(ntriplets) = dof(i); + J(ntriplets) = dof(j); + X(ntriplets) = ke(dofLocal(i), dofLocal(j), p); end - Sbot(m, 2) = L1 * L2; - Sbot(m, 3:5) = [0, 0, -1]; - Stop(m, 2) = L1 * L2; - Stop(m, 3:5) = [0, 0, 1]; - m = m + 1; end - end - - m = 1; - - for k = 2:mz - - for i = 2:mx - %front surface of beam (t=0) - gn = i + (k - 1) * (mx + 1); - Sfront(m) = gn; %(y=0) - - gn = i + (k - 1) * (mx + 1) + (mx + 1) * (mz + 1) * my; - Sback(m) = gn; %(y=dy) - - L1 = w; - L3 = d; - Sfront(m, 2) = L1 * L3; - Sfront(m, 3:5) = [0, -1, 0]; - Sback(m, 2) = L1 * L3; - Sback(m, 3:5) = [0, 1, 0]; - - m = m + 1; - end + % K{N}(dof,dof)= K{N}(dof,dof)+Ke(dofLocal,dofLocal,p); %the (full) global stiffness matrix end -else - disp('error; only coded for end loadeded cantilever') - pause -end - -if loading == 1% end loaded cantilever - - gammat = [Stop; Sbot; Sright; Sfront; Sback]; % t=0 - gammau = Sleft; % set containg fixed nodes u=0 - gammaMixed = Smixed; % t1=t2=0, u3= U - - fixedDofs = [3 * gammau(:, 1) - 2; 3 * gammau(:, 1) - 1; 3 * gammau(:, 1); 3 * gammaMixed(:, 1)]; - freeDofs = [3 * gammat(:, 1) - 2; 3 * gammat(:, 1) - 1; 3 * gammat(:, 1); 3 * gammaMixed(:, 1) - 2; ... - 3 * gammaMixed(:, 1) - 1]; - -elseif loading == 0% used for debugging - - Sright = [Sright; Smixed]; - % - % - % gnr = (mx+1); % x(gnr) = [dx 0 0] u3 = 0 -> R(x2)=0; u2 = 0 -> R(x3)=0 - % gnl = [(mx+1)*(mz+1)*my+1]; % x(gnl) = [0 dy 0] u3 = 0 -> R(x1)=0 - % - % Smixed = [Sright(ismember(Sright(:,1), gnr),:); Sleft(ismember(Sleft(:,1),gnl),:)]; - % - % - % gammat=[Stop;Sbot;Sfront;Sback;... - % Sright(~ismember(Sright(:,1), gnr),:); Sleft(~ismember(Sleft(:,1),[1,gnl]),:)]; % t=0 - % - % gammau = Sleft(ismember(Sleft(:,1),1),:); - % - % gammaMixed=Smixed; - % fixedDofs =[3*gammau(:,1)-2; 3*gammau(:,1)-1; 3*gammau(:,1);... - % 3*gammaMixed(1,1); 3*gammaMixed(1,1)-1; 3*gammaMixed(2,1)]; - % freeDofs = [3*gammat(:,1)-2; 3*gammat(:,1)-1; 3*gammat(:,1);... - % 3*gammaMixed(1,1)-2; 3*gammaMixed(2,1)-2; 3*gammaMixed(2,1)-1]; - - Smixed = []; - gammaMixed = Smixed; - gammat = []; - gammau = [Stop; Sbot; Sleft; Sright; Sfront; Sback]; - - fixedDofs = [3 * gammau(:, 1) - 2; 3 * gammau(:, 1) - 1; 3 * gammau(:, 1)]; - - freeDofs = []; -else - disp('loading not specified correctly') - pause -end + kg = sparse(I, J, X, 3 * mno, 3 * mno); %the (full) global stiffness matrix -for m = 1:length(fixedDofs) - i = fixedDofs(m); - K(:, i) = 0; - K(i, :) = 0; - K(i, i) = bcwt; + toc end - -if length([fixedDofs; freeDofs]) > length(unique([fixedDofs; freeDofs])) - disp('error') - pause -end - -% {freeDofs,fixedDofs} should contain every degree of freedom on boundary + -% any internal Dofs with a force or displacement specified. -figure(2); clf; hold on; view(3) -xlabel('x'); ylabel('y'); zlabel('z') -plot3(xnodes(Stop(:, 1), 1), xnodes(Stop(:, 1), 2), xnodes(Stop(:, 1), 3), 'r*') -plot3(xnodes(Sbot(:, 1), 1), xnodes(Sbot(:, 1), 2), xnodes(Sbot(:, 1), 3), 'r*') -plot3(xnodes(Sright(:, 1), 1), xnodes(Sright(:, 1), 2), xnodes(Sright(:, 1), 3), 'b.') -plot3(xnodes(Sleft(:, 1), 1), xnodes(Sleft(:, 1), 2), xnodes(Sleft(:, 1), 3), 'b.') -plot3(xnodes(Sfront(:, 1), 1), xnodes(Sfront(:, 1), 2), xnodes(Sfront(:, 1), 3), 'k*') -plot3(xnodes(Sback(:, 1), 1), xnodes(Sback(:, 1), 2), xnodes(Sback(:, 1), 3), 'k*') -% plot3(xnodes(Smixed(:,1),1),xnodes(Smixed(:,1),2),xnodes(Smixed(:,1),3),'g*') -axis('equal') -hold off - -% disp('LU decomposition of K...') -% %L=0;U=0; -% tic; -% [L,U] = lu(K); -% toc; - -disp('Cholesky Factorization of K...'); %should be symmetric! -tic; -U = chol(K); -L = U'; -toc; - -% if max(abs(diag( U\(L\K) )))-1 > 1000*eps -% disp('Error in inverse K') -% pause -% end - -disp('finished FEM') -%------------------------------------------------------------------- diff --git a/src/fixBlockadingNodes.m b/src/fixBlockadingNodes.m new file mode 100644 index 00000000..8a45003c --- /dev/null +++ b/src/fixBlockadingNodes.m @@ -0,0 +1,16 @@ +function rnnew = fixBlockadingNodes(rnnew) + + %find blockading fixed nodes and allow code to deal with them + for i = 1:size(rnnew, 1) + + if rnnew(i, end) ~= 7 + continue + end + + if connectivitynew(i, 1) > 7 + rnnew(i, end) = 0; + end + + end + +end diff --git a/src/forceControl.m b/src/forceControl.m new file mode 100644 index 00000000..0b6de26a --- /dev/null +++ b/src/forceControl.m @@ -0,0 +1,6 @@ +function [u, u_bar, f, f_bar, calculateR_hat] = forceControl(u, u_dot, sign_u_dot, f, f_dot, sign_f_dot, simTime, gamma_mixed) + u_bar = 0; + f_bar = f_dot * simTime; + f(3 * gamma_mixed(:, 1)) = sign_f_dot * f_bar; + calculateR_hat = false; +end diff --git a/src/genconnectivity.m b/src/genconnectivity.m index 07fb723c..ae31cdf5 100644 --- a/src/genconnectivity.m +++ b/src/genconnectivity.m @@ -5,8 +5,6 @@ % connectivity(i,1)= number of links that node i is part of % connectivity(i,2:7)= the list of connectivity(i,1) links that node i is part of - % disp('Initiliazing connectivity list.'); - rnlength = length(rn(:, 4)); connectivity = zeros(rnlength, 1 + 2 * maxconnections); linkslength = length(links(:, 1)); diff --git a/src/inputCompletion.m b/src/inputCompletion.m index 1cea17d1..0589ebec 100644 --- a/src/inputCompletion.m +++ b/src/inputCompletion.m @@ -48,8 +48,8 @@ end if ~exist('loading', 'var') - loading = 1; - fprintf('Providing default value for loading = %d.', loading) + loading = 'displacementControl'; + fprintf('Providing default value for loading = %s.', loading) end if ~exist('vertices', 'var') @@ -202,9 +202,19 @@ fprintf('Providing default value for printfreq = %d.\n', printfreq) end -if ~exist('plotfreq', 'var') - plotfreq = 100; - fprintf('Providing default value for plotfreq = %d.\n', plotfreq) +if ~exist('plotFreq', 'var') + plotFreq = 100; + fprintf('Providing default value for plotFreq = %d.\n', plotFreq) +end + +if ~exist('simName', 'var') + simName = date; + fprintf('Providing default value for saveFreq = %s.\n', simName) +end + +if ~exist('saveFreq', 'var') + saveFreq = 100; + fprintf('Providing default value for saveFreq = %d.\n', saveFreq) end if ~exist('plim', 'var') @@ -257,14 +267,9 @@ fprintf('Providing default value for f_dot = %d.\n', f_dot) end -if ~exist('loading', 'var') - loading = 1; - fprintf('Providing default value for loading = %d.\n', loading) -end - if ~exist('simType', 'var') - simType = 1; - fprintf('Providing default value for simType = %d.\n', simType) + simType = 'cantileverBending'; + fprintf('Providing default value for simType = %s.\n', simType) end if ~exist('Fsim', 'var') diff --git a/src/mergenodes.m b/src/mergenodes.m index 4149c416..e3dfd356 100644 --- a/src/mergenodes.m +++ b/src/mergenodes.m @@ -143,9 +143,6 @@ end -%disp(sprintf('node %d and node %d have successfully merged',nodeid,deadnode)) -% nodes have been successfully merged - function [links, connectivity, linksinconnect, fseg] = removelink(links, connectivity, linksinconnect, fseg, linkid) % this subroutine is called by meshcoarsen % this subroutine deletes the link information from the connectivity list diff --git a/src/mobbcc_bb1b.m b/src/mobbcc_bb1b.m index b58ac9dd..68fcd376 100644 --- a/src/mobbcc_bb1b.m +++ b/src/mobbcc_bb1b.m @@ -142,7 +142,7 @@ end if ~isequal(size(cosdev_alt), [1 1]) ||~isequal(size(slipplanes, 1), size(dotprods2_alt, 1)) ||~isequal(size(dotprods2_alt, 2), 1) - disp('YDFUS') + fprintf('mobbcc_bb1b: erroneous slip planes\n') end ndir_alt = slipplanes(dotprods2_alt == cosdev_alt, :); @@ -190,19 +190,6 @@ if norm(Btotal) < eps vn(n, :) = [0 0 0]; elseif rcond(Btotal) < 1e-15 - - % [evec,eval]=eig(Btotal); % find eigenvalues and eigen vectors of drag matrix - % evalmax=eval(1,1); - % eval=eval./evalmax; - % fvec=fn(n,:)'./evalmax; - % for i=2:3 % invert drag matrix and keep zero eigen values as zero - % if eval(i,i)>tol - % eval(i,i)=1/eval(i,i); - % else - % eval(i,i)=0.0d0; - % end - % end - % vn(n,:)=(evec*eval*evec'*fvec)'; % calculate the velocity Btotal_temp = Btotal + 1e-6 * max(max(abs(Btotal))) * eye(3); Btotal_temp2 = Btotal - 1e-6 * max(max(abs(Btotal))) * eye(3); vn_temp = (Btotal_temp \ fn(n, :)')'; @@ -213,19 +200,9 @@ end if any(isnan(vn)) - disp('YDFUS, see line 157 of mobbcc_bb1b'); + fprintf('YDFUS, see line 157 of mobbcc_bb1b\n'); end - % if numNbrs==2 - % ii=conlist(n,2); - % n1=links(connectivity(n0,2*ii),3-connectivity(n0,2*ii+1)); - % ii=conlist(n,3); - % n2=links(connectivity(n0,2*ii),3-connectivity(n0,2*ii+1)); - % rt=rn(n1,1:3)-rn(n2,1:3); - % L=norm(rt); - % linedir=rt./L; - % vn(n,:)=((eye(3)-linedir'*linedir)*vn(n,:)')'; - % end end end diff --git a/src/plotFEMDomain.m b/src/plotFEMDomain.m new file mode 100644 index 00000000..8ecf6fc8 --- /dev/null +++ b/src/plotFEMDomain.m @@ -0,0 +1,13 @@ +function fig = plotFEMDomain(Stop, Sbot, Sright, Sleft, Sfront, Sback, Smixed, xnodes) + fig = figure(1); clf; hold on; view(3) + xlabel('x'); ylabel('y'); zlabel('z') + plot3(xnodes(Stop(:, 1), 1), xnodes(Stop(:, 1), 2), xnodes(Stop(:, 1), 3), 'r*') + plot3(xnodes(Sbot(:, 1), 1), xnodes(Sbot(:, 1), 2), xnodes(Sbot(:, 1), 3), 'r*') + plot3(xnodes(Sright(:, 1), 1), xnodes(Sright(:, 1), 2), xnodes(Sright(:, 1), 3), 'b.') + plot3(xnodes(Sleft(:, 1), 1), xnodes(Sleft(:, 1), 2), xnodes(Sleft(:, 1), 3), 'b.') + plot3(xnodes(Sfront(:, 1), 1), xnodes(Sfront(:, 1), 2), xnodes(Sfront(:, 1), 3), 'k*') + plot3(xnodes(Sback(:, 1), 1), xnodes(Sback(:, 1), 2), xnodes(Sback(:, 1), 3), 'k*') + plot3(xnodes(Smixed(:, 1), 1), xnodes(Smixed(:, 1), 2), xnodes(Smixed(:, 1), 3), 'g*') + axis('equal') + hold off +end diff --git a/src/plotSimulation.m b/src/plotSimulation.m new file mode 100644 index 00000000..4dc71bb0 --- /dev/null +++ b/src/plotSimulation.m @@ -0,0 +1,13 @@ +function plotSimulation(Usim, Fsim, rn, links, plim, vertices, plotFreq, viewangle, plotForceDisp, amag, mumag, curstep) + + if (mod(curstep, plotFreq) == 0) + figure(1) + plotnodes(rn, links, plim, vertices); + view(viewangle); + drawnow + + feval(plotForceDisp, Usim, Fsim, amag, mumag, curstep); + pause(0.01); + end + +end diff --git a/src/processForceDisp.m b/src/processForceDisp.m deleted file mode 100644 index 429d9bd9..00000000 --- a/src/processForceDisp.m +++ /dev/null @@ -1,9 +0,0 @@ -function [f_out, u_out] = processForceDisp(f_bar, f_hat, f_tilda, u_bar, u_hat, u_tilda, r_hat, gamma_disp, ... - gamma_mixed, fixedDofs, freeDofs, simType) - - if simType == 1 - f_out = sum(r_hat(3 * gamma_mixed(:, 1)) + f_tilda(3 * gamma_mixed(:, 1))); - u_out = u_bar; - end - -end diff --git a/src/remeshPreCollision.m b/src/remeshPreCollision.m new file mode 100644 index 00000000..ff70b17f --- /dev/null +++ b/src/remeshPreCollision.m @@ -0,0 +1,20 @@ +function [rnnew, linksnew, connectivitynew, linksinconnectnew, fsegnew] = remeshPreCollision(rnnew, linksnew, ... + connectivitynew, linksinconnectnew, fsegnew, lmin, lmax, areamin, areamax, MU, NU, a, Ec, ... + mobility, doremesh, dovirtmesh, vertices, u_hat, nc, xnodes, D, mx, mz, w, h, d, ... + TriangleCentroids, TriangleNormals, CUDA_flag, Bcoeff) + + if doremesh% do virtual re-meshing first + %remeshing virtual dislocation structures + if dovirtmesh + [rnnew, linksnew, connectivitynew, linksinconnectnew, fsegnew] = virtualmeshcoarsen(rnnew, linksnew, ... + connectivitynew, linksinconnectnew, fsegnew, MU, NU, a, Ec); + end + + %remeshing internal dislocation structures + [rnnew, linksnew, connectivitynew, linksinconnectnew, fsegnew] = remesh_all(rnnew, linksnew, ... + connectivitynew, linksinconnectnew, fsegnew, lmin, lmax, areamin, areamax, MU, NU, a, Ec, ... + mobility, doremesh, dovirtmesh, vertices, u_hat, nc, xnodes, D, mx, mz, w, h, d, ... + TriangleCentroids, TriangleNormals, CUDA_flag, Bcoeff); + end + +end diff --git a/src/remesh_all.m b/src/remesh_all.m index 15c92c12..2598b9a3 100644 --- a/src/remesh_all.m +++ b/src/remesh_all.m @@ -10,13 +10,14 @@ % January 2014 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -function [rnnew, linksnew, connectivitynew, linksinconnectnew, fsegnew] = remesh_all(rn, links, connectivity, linksinconnect, fseg, lmin, lmax, areamin, areamax, MU, NU, a, Ec, mobility, doremesh, dovirtmesh, vertices, ... - uhat, nc, xnodes, D, mx, mz, w, h, d, P, fn, CUDA_flag, Bcoeff) +function [rnnew, linksnew, connectivitynew, linksinconnectnew, fsegnew] = remesh_all(rn, links, ... + connectivity, linksinconnect, fseg, lmin, lmax, areamin, areamax, MU, NU, a, Ec, mobility, ... + doremesh, dovirtmesh, vertices, uhat, nc, xnodes, D, mx, mz, w, h, d, P, fn, CUDA_flag, Bcoeff) - % Original remesh rule %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - if (dovirtmesh) - % Beginning of surface remeshing for surface node. %%%%%%%%%%%%%%%%%%%% - [rnnew, linksnew, connectivitynew, linksinconnectnew, fsegnew] = remesh_surf(rn, links, connectivity, linksinconnect, fseg, vertices, P, fn); + if dovirtmesh + % Beginning of surface remeshing for surface node. + [rnnew, linksnew, connectivitynew, linksinconnectnew, fsegnew] = remesh_surf(rn, links, ... + connectivity, linksinconnect, fseg, vertices, P, fn); else rnnew = rn; linksnew = links; @@ -25,27 +26,10 @@ fsegnew = fseg; end - % if (doremesh) - % [rnnew,linksnew,connectivitynew,linksinconnectnew,fsegnew]=remesh(rn,links,connectivity,linksinconnect,fseg,lmin,lmax,areamin,areamax,MU,NU,a,Ec,mobility,vertices,... - % uhat,nc,xnodes,D,mx,mz,w,h,d); - % end - - % if doremesh == 0 %to enter in remesh_all doremesh has to be 1.. so is the loop useless? M - % rnnew = rn; - % linksnew = links; - % fsegnew = fseg; - % connectivitynew = connectivity; - % linksinconnectnew = linksinconnect; - % end - - if (doremesh) - [rnnew, linksnew, connectivitynew, linksinconnectnew, fsegnew] = remesh(rnnew, linksnew, connectivitynew, linksinconnectnew, fsegnew, lmin, lmax, areamin, areamax, MU, NU, a, Ec, mobility, vertices, ... - uhat, nc, xnodes, D, mx, mz, w, h, d, CUDA_flag, Bcoeff); + if doremesh + [rnnew, linksnew, connectivitynew, linksinconnectnew, fsegnew] = remesh(rnnew, linksnew, ... + connectivitynew, linksinconnectnew, fsegnew, lmin, lmax, areamin, areamax, MU, NU, a, ... + Ec, mobility, vertices, uhat, nc, xnodes, D, mx, mz, w, h, d, CUDA_flag, Bcoeff); end - % if (dovirtmesh) - % % Beginning of surface remeshing for surface node. %%%%%%%%%%%%%%%%%%%% - % [rnnew,linksnew,connectivitynew,linksinconnectnew,fsegnew]=remesh_surf(rnnew,linksnew,connectivitynew,linksinconnectnew,fsegnew,vertices,P,fn); - % end - end diff --git a/src/remesh_surf.m b/src/remesh_surf.m index 08c45996..959d8c3e 100644 --- a/src/remesh_surf.m +++ b/src/remesh_surf.m @@ -123,7 +123,7 @@ rnnew = extend(rnnew, linksnew, i, index, fn); if any(any(isnan(rnnew))) - disp('The new extended node is NaN! See Line 46 in remesh_surf.m'); + fprintf('The new extended node is NaN! See Line 46 in remesh_surf.m\n'); pause; end diff --git a/src/saveSimulation.m b/src/saveSimulation.m new file mode 100644 index 00000000..6207c6ca --- /dev/null +++ b/src/saveSimulation.m @@ -0,0 +1,8 @@ +function saveSimulation(simName, curstep, saveFreq) + + if mod(curstep, saveFreq) == 0 + close all; + save(sprintf('../output/%s_%d', simName, curstep)); + end + +end diff --git a/src/segforcevec.m b/src/segforcevec.m index cc1a653d..f9b088e7 100644 --- a/src/segforcevec.m +++ b/src/segforcevec.m @@ -12,7 +12,7 @@ [~, m] = size(rn); if (m ~= 4) - disp('rn should have 4 columns!'); + fprintf('rn should have 4 columns!\n'); return; end @@ -31,15 +31,13 @@ % segments = segments(index,:); if any(any(isnan(segments))) - disp('YDFUS, see line 32 segforcevec.m') + fprintf('YDFUS, see line 32 segforcevec.m\n') end if linkid == 0%calculate forces on all segments %PK force due to applied stress - %t0=clock; fpk = pkforcevec(uhat, nc, xnodes, D, mx, mz, w, h, d, segments); - %t=etime(clock,t0); disp(sprintf('pkforcevec time = %6.2f seconds\n',t)); %self force due to self stress [fs0, fs1] = selfforcevec(MU, NU, a, Ec, segments); @@ -48,7 +46,6 @@ [fr0, fr1] = remoteforcevec(MU, NU, a, segments, 0, CUDA_flag); %PK force due to image stress - %fimg = imageforce(segments,a,MU,NU,vertices); fseg = [fpk, fpk] * 0.5 + [fs0, fs1] + [fr0, fr1]; %combine all force contributions @@ -76,9 +73,7 @@ end %PK force due to applied stress - %t0=clock; fpk = pkforcevec(uhat, nc, xnodes, D, mx, mz, w, h, d, segments(linkid, :)); - %t=etime(clock,t0); disp(sprintf('pkforcevec time = %6.2f seconds\n',t)); %self force due to self stress [fs0, fs1] = selfforcevec(MU, NU, a, Ec, segments(linkid, :)); @@ -120,7 +115,7 @@ xi = rmid(i, 1:3); if any(isnan(xi)) - disp('Segment midpoint is undefined! See segforcevec.m'); + fprintf('Segment midpoint is undefined! See segforcevec.m\n'); pause; end diff --git a/src/separation.m b/src/separation.m index 045356bb..f08e267e 100644 --- a/src/separation.m +++ b/src/separation.m @@ -1,5 +1,15 @@ -function [rn, links, connectivity, linksinconnect, fseg] = separation(rn, links, connectivity, linksinconnect, fseg, mobility, MU, NU, a, Ec, mindist, vertices, ... - uhat, nc, xnodes, D, mx, mz, w, h, d, CUDA_flag, Bcoeff) +function [rn, links, connectivity, linksinconnect, fseg] = separation(doseparation, rn, ... + links, connectivity, linksinconnect, fseg, mobility, MU, NU, a, Ec, mindist, ... + vertices, uhat, nc, xnodes, D, mx, mz, w, h, d, CUDA_flag, Bcoeff) + + if ~doseparation + return + end + + % Spliting nodes with 4 or more connections. + if max(connectivity(:, 1)) < 4 + return + end [lrn, lrn2] = size(rn); i = 1; @@ -14,7 +24,6 @@ c = connectivity(i, 1); if (c > 3) && (rn(i, lrn2) == 0) - % disp(sprintf('separation: node %d has %d arms',i,c)); % a high order node has been found % calculate the power dissipated by the connected geometry and not splitting ft = zeros(1, 3); @@ -178,10 +187,6 @@ end fprintf('separation: node %d has %d arms\n', i, c); - % disp(sprintf('separation: the following connections have split off')); - % for j=1:length(s) - % disp(sprintf('separation: connection %d',s(j))); - % end % get the positions and velocities of the nodes after the split vel1 = splittingvel(1, :); vel2 = splittingvel(2, :); diff --git a/src/splitnode.m b/src/splitnode.m index c78b404b..b8d584bd 100644 --- a/src/splitnode.m +++ b/src/splitnode.m @@ -8,7 +8,7 @@ if ((testl == 0) | (testl == connectivity(nodeid, :)) | (max(splitconnections) > connectivity(nodeid, :))) %sanity check% - disp('node was not split because of a problem with the connections to be split'); + fprintf('node was not split because of a problem with the connections to be split\n'); return; end @@ -86,8 +86,6 @@ end - %disp(sprintf('node %d has split into node %d and node %d',nodeid,nodeid,newnodeid)); - % end of function splitnode end function [connectivity, linksinconnect] = removedeadconnection(connectivity, linksinconnect, nodeid, deadconnection) diff --git a/src/updateForceDispTime.m b/src/updateForceDispTime.m deleted file mode 100644 index 783f1af4..00000000 --- a/src/updateForceDispTime.m +++ /dev/null @@ -1,9 +0,0 @@ -function [Fsim, Usim, t] = updateForceDispTime(Fsim, Usim, t, f_out, u_out, simTime, curstep, simType) - - if simType == 1 - Fsim(curstep + 1) = f_out; - Usim(curstep + 1) = u_out; - t(curstep + 1) = simTime; - end - -end diff --git a/src/updateMatricesBackward.m b/src/updateMatricesBackward.m new file mode 100644 index 00000000..12439b7a --- /dev/null +++ b/src/updateMatricesBackward.m @@ -0,0 +1,9 @@ +function [rn, vn, links, connectivity, linksinconnect, fseg] = updateMatricesBackward(rnnew, ... + linksnew, connectivitynew, linksinconnectnew, fsegnew) + rn = [rnnew(:, 1:3) rnnew(:, 7)]; + vn = rnnew(:, 4:6); + links = linksnew; + connectivity = connectivitynew; + linksinconnect = linksinconnectnew; + fseg = fsegnew; +end diff --git a/src/updateMatricesForward.m b/src/updateMatricesForward.m new file mode 100644 index 00000000..a0b9d7f4 --- /dev/null +++ b/src/updateMatricesForward.m @@ -0,0 +1,8 @@ +function [rnnew, linksnew, connectivitynew, linksinconnectnew, fsegnew] = updateMatricesForward(rnnew, ... + vn, links, connectivity, linksinconnect, fseg) + rnnew = [rnnew(:, 1:3) vn rnnew(:, 4)]; + linksnew = links; + connectivitynew = connectivity; + linksinconnectnew = linksinconnect; + fsegnew = fseg; +end diff --git a/src/updateTime.m b/src/updateTime.m new file mode 100644 index 00000000..955c0d5d --- /dev/null +++ b/src/updateTime.m @@ -0,0 +1,4 @@ +function [curstep, simTime] = updateTime(curstep, simTime, dt) + curstep = curstep + 1; + simTime = simTime + dt; +end diff --git a/src/wip/DanielCelisGarza/AnalyticNumericTractions/HeadVsFEM_ReactionForce.m b/src/wip/DanielCelisGarza/AnalyticNumericTractions/HeadVsFEM_ReactionForce.m index 832e0938..ce445bb2 100644 --- a/src/wip/DanielCelisGarza/AnalyticNumericTractions/HeadVsFEM_ReactionForce.m +++ b/src/wip/DanielCelisGarza/AnalyticNumericTractions/HeadVsFEM_ReactionForce.m @@ -154,7 +154,7 @@ close all - % save(sprintf('./mat_files/headVsFEM_%d', cntr)) + % save(fprintf('./mat_files/headVsFEM_%d', cntr)) % figCounter = figCounter + 1; % figure(figCounter) diff --git a/src/wip/DanielCelisGarza/AnalyticNumericTractions/imageForceComparison.m b/src/wip/DanielCelisGarza/AnalyticNumericTractions/imageForceComparison.m index 20beafe4..a82406d4 100644 --- a/src/wip/DanielCelisGarza/AnalyticNumericTractions/imageForceComparison.m +++ b/src/wip/DanielCelisGarza/AnalyticNumericTractions/imageForceComparison.m @@ -782,7 +782,7 @@ xi = rmid(i, 1:3); if any(isnan(xi)) - disp('Segment midpoint is undefined! See segforcevec.m'); + fprintf('Segment midpoint is undefined! See segforcevec.m\n'); pause; end diff --git a/src/wip/DanielCelisGarza/AnalyticNumericTractions/num_vs_ana_tractions.m b/src/wip/DanielCelisGarza/AnalyticNumericTractions/num_vs_ana_tractions.m index a5693922..fe552434 100644 --- a/src/wip/DanielCelisGarza/AnalyticNumericTractions/num_vs_ana_tractions.m +++ b/src/wip/DanielCelisGarza/AnalyticNumericTractions/num_vs_ana_tractions.m @@ -72,7 +72,7 @@ % mean(ftilda_n - ftilda_a_par) % Plotting - % save(sprintf('mx=%d_face=%d', mx, face), 'ftilda_a_lin', 'ftilda_a_par', 'ftilda_n', 'dim', 'face', 'midpoint_element') + % save(fprintf('mx=%d_face=%d', mx, face), 'ftilda_a_lin', 'ftilda_a_par', 'ftilda_n', 'dim', 'face', 'midpoint_element') % plot_figs(face, dim, ftilda_n, ftilda_a_lin, x, y, z); end %for @@ -89,7 +89,7 @@ for face = min_face:stp_face:max_face for mx = 100:stp_mx:max_mx - load(sprintf('mx=%d_face=%d', mx, face)); + load(fprintf('mx=%d_face=%d', mx, face)); rms_rel_err_val(face, cntr, :) = ... plot_figs(face, dim, ftilda_n, ftilda_a_lin, ... midpoint_element(:, 1), midpoint_element(:, 2), ... @@ -270,9 +270,9 @@ caxis(colorvec); colorbar - title(sprintf('Relative Error, $F_{%s}$', str_dim(i)), 'Interpreter', 'latex'); - ylabel(sprintf('$%s$', str_label(2)), 'Interpreter', 'latex'); - xlabel(sprintf('$%s$', str_label(1)), 'Interpreter', 'latex'); + title(fprintf('Relative Error, $F_{%s}$', str_dim(i)), 'Interpreter', 'latex'); + ylabel(fprintf('$%s$', str_label(2)), 'Interpreter', 'latex'); + xlabel(fprintf('$%s$', str_label(1)), 'Interpreter', 'latex'); axis equal end %for @@ -287,9 +287,9 @@ colorvec = [min(cvec) max(cvec)]; %[min(f_dln_a(:, i))*(mean_rel_err + 1) max(f_dln_a(:, i))*(mean_rel_err + 1)]; caxis(colorvec); colorbar - title(sprintf('$F^{A}_{%s}$', str_dim(i)), 'Interpreter', 'latex'); - ylabel(sprintf('$%s$', str_label(2)), 'Interpreter', 'latex'); - xlabel(sprintf('$%s$', str_label(1)), 'Interpreter', 'latex'); + title(fprintf('$F^{A}_{%s}$', str_dim(i)), 'Interpreter', 'latex'); + ylabel(fprintf('$%s$', str_label(2)), 'Interpreter', 'latex'); + xlabel(fprintf('$%s$', str_label(1)), 'Interpreter', 'latex'); axis equal end %for @@ -303,9 +303,9 @@ colorvec = [min(cvec) max(cvec)]; caxis(colorvec); colorbar - title(sprintf('$F^{A}_{%s}$', str_dim(i)), 'Interpreter', 'latex'); - ylabel(sprintf('$%s$', str_label(2)), 'Interpreter', 'latex'); - xlabel(sprintf('$%s$', str_label(1)), 'Interpreter', 'latex'); + title(fprintf('$F^{A}_{%s}$', str_dim(i)), 'Interpreter', 'latex'); + ylabel(fprintf('$%s$', str_label(2)), 'Interpreter', 'latex'); + xlabel(fprintf('$%s$', str_label(1)), 'Interpreter', 'latex'); axis equal end %for diff --git a/src/wip/DanielCelisGarza/AnalyticNumericTractions/test_fpoint.m b/src/wip/DanielCelisGarza/AnalyticNumericTractions/test_fpoint.m index b856402d..46968ca3 100644 --- a/src/wip/DanielCelisGarza/AnalyticNumericTractions/test_fpoint.m +++ b/src/wip/DanielCelisGarza/AnalyticNumericTractions/test_fpoint.m @@ -50,13 +50,13 @@ nodal_surface_force_linear_rectangle_mex(x1, x2, ... x3, x4, x5, x6, b, mu, nu, a, 1, 1, 0.0); ftota = ftota'; - save(sprintf("./worst_case/aeperp_%f_%f_x3.mat", x1(1, 3), x2(end, 3)), "ftota") + save(fprintf("./worst_case/aeperp_%f_%f_x3.mat", x1(1, 3), x2(end, 3)), "ftota") end %if - save(sprintf("./worst_case/neperp_%d_%f_%f_x3.mat", n_q(i), x1(1, 3), x2(end, 3)), "ftotn") + save(fprintf("./worst_case/neperp_%d_%f_%f_x3.mat", n_q(i), x1(1, 3), x2(end, 3)), "ftotn") end %for - % sprintf("q = %d, dist = %f, err = %f, ", n_q(i), dist(j), abs(ftotn(2)-ftota(2))./ftota(2)) + % fprintf("q = %d, dist = %f, err = %f, ", n_q(i), dist(j), abs(ftotn(2)-ftota(2))./ftota(2)) end %for end %for @@ -93,10 +93,10 @@ nodal_surface_force_linear_rectangle_mex(reshape(x1', dim, 1), reshape(x2', dim, 1), ... x3, x4, x5, x6, b, mu, nu, a, 1, n_dln, 1e-6); ftota = ftota'; - save(sprintf("./worst_case/aepar_%f_%f_x3x6.mat", x1(1, 3), x2(end, 3)), "ftota") + save(fprintf("./worst_case/aepar_%f_%f_x3x6.mat", x1(1, 3), x2(end, 3)), "ftota") end %if - save(sprintf("./worst_case/nepar_%d_%f_%f_x3x6.mat", n_q(i), x1(1, 3), x2(end, 3)), "ftotn") + save(fprintf("./worst_case/nepar_%d_%f_%f_x3x6.mat", n_q(i), x1(1, 3), x2(end, 3)), "ftotn") end %for end %for @@ -133,9 +133,9 @@ % nodal_surface_force_linear_rectangle_mex(reshape(x1',dim,1), reshape(x2',dim,1), ... % x3, x4, x5, x6, b, mu, nu, a, 1, n_dln, 1e-6); % ftota = ftota'; -% save(sprintf("aspar_%f_%f.mat", x1(1,3), x2(end,3)), "ftota") +% save(fprintf("aspar_%f_%f.mat", x1(1,3), x2(end,3)), "ftota") % end %if -% save(sprintf("nspar_%d_%f_%f.mat", n_q(i), x1(1,3), x2(end,3)), "ftotn") +% save(fprintf("nspar_%d_%f_%f.mat", n_q(i), x1(1,3), x2(end,3)), "ftotn") % end %for % end %for %% @@ -174,9 +174,9 @@ % % nodal_surface_force_linear_rectangle_mex(x1, x2, ... % % x3, x4, x5, x6, b, mu, nu, a, 1, 1); % % ftota = ftota'; -% % save(sprintf("aaeperp_%f_%f.mat", x1(1,3), x2(end,3)), "ftota") +% % save(fprintf("aaeperp_%f_%f.mat", x1(1,3), x2(end,3)), "ftota") % % end %if -% % save(sprintf("aneperp_%d_%f_%f.mat", n_q(i), x1(1,3), x2(end,3)), "ftotn") +% % save(fprintf("aneperp_%d_%f_%f.mat", n_q(i), x1(1,3), x2(end,3)), "ftotn") % % end %for % % end %for % % end %for @@ -210,9 +210,9 @@ % nodal_surface_force_linear_rectangle_mex(reshape(x1',dim,1), reshape(x2',dim,1), ... % x3, x4, x5, x6, b, mu, nu, a, 1, n_dln); % ftota = ftota'; -% % save(sprintf("aaepar_%f_%f.mat", x1(1,3), x2(end,3)), "ftota") +% % save(fprintf("aaepar_%f_%f.mat", x1(1,3), x2(end,3)), "ftota") % end %if -% % save(sprintf("anepar_%d_%f_%f.mat", n_q(i), x1(1,3), x2(end,3)), "ftotn") +% % save(fprintf("anepar_%d_%f_%f.mat", n_q(i), x1(1,3), x2(end,3)), "ftotn") % end %for % end %for % end %for @@ -251,9 +251,9 @@ % nodal_surface_force_linear_rectangle_mex(reshape(x1',dim,1), reshape(x2',dim,1), ... % x3, x4, x5, x6, b, mu, nu, a, 1, n_dln); % ftota = ftota'; -% % save(sprintf("aaspar_%f_%f.mat", x1(1,3), x2(end,3)), "ftota") +% % save(fprintf("aaspar_%f_%f.mat", x1(1,3), x2(end,3)), "ftota") % end %if -% % save(sprintf("anspar_%d_%f_%f.mat", n_q(i), x1(1,3), x2(end,3)), "ftotn") +% % save(fprintf("anspar_%d_%f_%f.mat", n_q(i), x1(1,3), x2(end,3)), "ftotn") % end %for % end %for % end %for