Informations

Projet 				: 	EPFL  Notebooks de démonstrations
Auteur		 		: 	Amina Matt
Date de création 		:	Avril 2019
But					: 	Défauts ponctuels et linéaires
Historique des révisions	:

Défauts

Théorie

Voir les slides du Cours no 6.1 pour plus de détails

Code

Pour évaluer toutes les cellules du notebook utiliser ⌘+A et  ⇧+↵  . Pour fermer la fenêtre de visualisation utiliser ⌘+W.

Initialisation

Réseau hexagonal

hexagonalLatticeVectors =N@ {{1,0},{1/2,Sqrt[3]/2}}; (*Basis vectors*)
pts =(#. hexagonalLatticeVectors  )&/@Tuples[Range[-45,45],2];

Pruning to a block (for subsequent pruning)

pts = Cases[pts,{x_,y_}/;(-20 ≤  x ≤  20 && -10 < y < 25)]; 
pts = Cases[pts,{x_,y_}/;(-5 ≤  x ≤  5 && -5 < y < 5)];
(*ptsGraphic =Graphics[Point[pts], Axes->True, ImageSize->Large];*)

Fonctions

(*Computation of the forces and energies of a particle system.*)

Potentiel

particleForcesAndEnergiesCompiled= Compile[{{positions,_Real,2}}, 
Block[{distanceMatSq,distanceMatSixth, differenceMat,ret},
differenceMat = Outer
[Subtract,N[positions],N[positions],1] ;
distanceMatSq =Map[#.#&,differenceMat,{2}] + IdentityMatrix[Length[positions]];
distanceMatSixth= distanceMatSq^3;
Flatten[{(* Here it is where LJ comes into place -> *)
(*Forces*)Total[-12 differenceMat ( 1-distanceMatSixth)/distanceMatSq^7],
(*Energies*)Total[(1-2distanceMatSixth)/(distanceMatSixth^2)]
}]
]
];

particleForcesAndEnergies[positions_]:= Module[{res},
res = particleForcesAndEnergiesCompiled[positions];
{Partition[Take[res,2 Length[positions]],2],
Take[res,- Length[positions]]}
]

Graphics

displayParticles[positions_, energies_,m_]:=Module[{},
Graphics[{
  Transpose[
   {
ColorData["Rainbow"][Sqrt@Clip[Rescale[#, {Min@energies, Max@energies}],{0,1}]] & /@ energies,
    Disk[#, 0.5] & /@ positions}
   ]},PlotRange->m,ImageSize->400]]

(*Function to display a colorbar legend*)

colorbar[energies_]:=Module[{allrange,allRangeColor,allcommand,allText,alldisk},
allrange=Table[i,{i,Min@energies, Max@energies,0.55}];
allRangeColor=ColorData["Rainbow"][Sqrt@Clip[Rescale[#, {Min@energies, Max@energies}],{0,1}]] & /@ allrange;
allcommand=Partition[Riffle[
   allRangeColor,  Disk[{7,#+6}, 0.5] & /@allrange],2];
allText=Graphics[{White,Text[
Style[NumberForm[#,{2,1}],Medium]
,{7,#+6}]}]& /@ allrange;
alldisk=Thread[Graphics[allcommand]];
Show[alldisk,allText]
]

perfectHexagonalLattice=Module[{points=pts},
{forces,energies}=particleForcesAndEnergies[points];
Show[colorbar[energies],displayParticles[points,energies,7]]
];

Démonstration 1 : Lacune

lacuneHexLattice=Module[{points=pts},
points=DeleteCases[points,Nearest[points,{1,0}][[1]]];
{forces,energies}=particleForcesAndEnergies[points];
Show[colorbar[energies],displayParticles[points,energies,7]]
]

lacuneVisualisation=Manipulate[Module[{points=pts},
points=DeleteCases[points,Nearest[points,p][[1]]];
{forces,energies}=particleForcesAndEnergies[points];
Show[colorbar[energies],displayParticles[points,energies,7]]
],
Style["Défaut de type lacune",Bold],
Style["Déplace ton curseur pour créer une lacune\n et observe le changement d'énergie dans\n les atomes voisins."],{{p,{0,0}},Locator},ControlPlacement->Left,LabelStyle->16];

Démonstration 2 : Défaut ponctuel substitutionnel

(*A substitutional defect introduce additional energy. Indeed, the distance is smaller than what it should be, r<(Subscript[r, 0]). The function to compute forces and energies, uses a normalized value, thus (Subscript[r, 0])=1. *)

substitutionnel=Module[{points=pts,subPoint={1,0},voisins,newvoisins,positions,forces,energies,sub},
voisins=Nearest[points, subPoint,7];(*neighbour of substitutional*)
newvoisins={1,0}+(#-{1,0})*1.08(*SUB*)&/@voisins; (*displaced*)
positions=Position[points,#][[1]]&/@voisins;(*positions in list around substitutional*)
MapThread[(points[[#[[1]]]]=#2)&,{positions,newvoisins}];
{forces,energies}=particleForcesAndEnergies[points]; (*all forces and energies*)
sub= Graphics[Disk[voisins[[1]], 1/2*1.2]];(*highlight of subsitutional*)
Show[{colorbar[energies],  displayParticles[points,energies,7],sub}]
]

substitutionnelVisualisation=
Manipulate[Module[{points=pts,voisins,newvoisins,positions,forces,energies,sub,subPoint},
subPoint=Nearest[points,p][[1]];
voisins=Nearest[points, subPoint,7];(*neighbour of substitutional*)
newvoisins=subPoint+(#-subPoint)*1.08(*SUB*)&/@voisins; (*displaced*)
positions=Position[points,#][[1]]&/@voisins;(*positions in list around substitutional*)
MapThread[(points[[#[[1]]]]=#2)&,{positions,newvoisins}];
{forces,energies}=particleForcesAndEnergies[points]; (*all forces and energies*)
sub= Graphics[Disk[voisins[[1]], 1/2*1.2]];(*highlight of subsitutional*)
Show[{colorbar[energies],  displayParticles[points,energies,7],sub}]
],
Style["Défaut de type substitutionnel",Bold],
Style["Déplace ton curseur pour substituer un atome\n et observe le changement d'énergie dans\n les atomes voisins."],{{p,{0,0},{-1,-1},{1,1}},Locator},ControlPlacement->Left,LabelStyle->16];

Démonstration 3 : Défaut ponctuel interstitiel

(*A substitutional defect introduce additional energy. Indeed, the distance is smaller than what it should be, r<(Subscript[r, 0]). The function to compute forces and energies, uses a normalized value, thus (Subscript[r, 0])=1. *)
interstitiel=Module[{points=pts(*,voisins,newvoisins,positions,forces,energies,sub*)},
intSite={0.5,Sqrt[3]/6};
intPoint=Nearest[points,{1,0}][[1]]+intSite;
voisins=Nearest[points, intPoint,3];(*neighbour of substitutional*)
newvoisins=intPoint+(#-intPoint)*1.1(*int*)&/@voisins; (*displaced*)
positions=Position[points,#][[1]]&/@voisins;(*positions in list around substitutional*)
MapThread[(points[[#[[1]]]]=#2)&,{positions,newvoisins}];
{forces,energies}=particleForcesAndEnergies[points]; (*all forces and energies*)
int= Graphics[Disk[intPoint, 1/2*0.5]];(*highlight of subsitutional*)
Show[{colorbar[energies],  displayParticles[points,energies,5],int}]
];

(*A substitutional defect introduce additional energy. Indeed, the distance is smaller than what it should be, r<(Subscript[r, 0]). The function to compute forces and energies, uses a normalized value, thus (Subscript[r, 0])=1. *)
interstitielVisualisation=Manipulate[Module[{points=pts(*,voisins,newvoisins,positions,forces,energies,sub*)},
intSite={0.5,Sqrt[3]/6};
intPoint=Nearest[points,p][[1]]+intSite;
voisins=Nearest[points, intPoint,3];(*neighbour of substitutional*)
newvoisins=intPoint+((#-intPoint)*1.15)(*int*)&/@voisins; (*displaced*)
positions=Position[points,#][[1]]&/@voisins;(*positions in list around substitutional*)
MapThread[(points[[#[[1]]]]=#2)&,{positions,newvoisins}];
{forces,energies}=particleForcesAndEnergies[points]; (*all forces and energies*)
int= Graphics[Disk[intPoint, 1/2*0.5]];(*highlight of subsitutional*)
Show[{colorbar[energies],  displayParticles[points,energies,5],int}]
],
Style["Défaut de type interstitiel",Bold],
Style["Déplace ton curseur pour rajouter un atome interstitiel\n et observe le changement d'énergie dans\n les atomes voisins."],{{p,{0,0},{-1,-1},{1,1}},Locator},ControlPlacement->Left,LabelStyle->16];

Démonstration 4 : Défaut linéaire dislocation coin

Visualisation en 2D avec vecteurs t and b

Fonctions

In order to illustrate the crystal structure with a dislocation we need to use the displacement field (i.e. it is a vector field which means at each point (x,y) the displacement is a vector (u(x.y),v(x,y))

The dimensionless form of the displacement field for an edge dislocation is the following.

u(x,y) =(( β)/(2π))[(tan^(-1))((x/y)) + (1/(2(1-ν)))((x y)/(r^2))] 
v(x,y) =(( β)/(2π))[((1- 2ν)/(2(1-ν))) log((β/r)) + (1/(2(1-ν)))((y^2)/(r^2))]

displacmentU[{x_,y_}(*distance between the point and the dislocation center*)]:=(β/(2 π))(ArcTan[x,y]+ ((x y)/(2(1-ν) ((x^2)+(y^2)))) ) 
displacmentV[{x_,y_}(*distance between the point and the dislocation center*)]:=(β/( 2π))( ((1- 2ν)/(2(1-ν))) Log[(β/(Sqrt[(x^2)+(y^2)]))]+(1/(2(1-ν)))((y^2)/((x^2)+(y^2))))

edgeDislocationLogo[xyVec_] :=Graphics@
  {Thickness[0.01], RGBColor[0,0.2,0], Translate[Line[{{{-0.125, 0},{0.125, 0}}, {{0, 0}, {0, 0.25}}}],xyVec]};

Visualisation

(*Initial Lattice*)
size=13;
basis=LatticeData["SquareLattice"]//Normal(*Lets make a simple 2D crystal structure*);
dislocationCenter={0,0};
allColors=Flatten[Table[ColorData["Rainbow"][#],{i,-(size-1)/2,(size-1)/2}]&/@Table[j,{j,0,1,1/(size-1)}]];

(*Functions final position and final lattice with β and ν values*)
finalPos[βValue_,νValue_,initialPositions_]:=
finalPos[βValue,νValue,initialPositions]=
#+{displacmentU[#-dislocationCenter]/.{β-> βValue,ν-> νValue},displacmentV[#-dislocationCenter]/.{β-> βValue,ν-> νValue}}&/@initialPositions

finalPosSimplified[βValue_,νValue_,initialPositions_]:=
finalPosSimplified[βValue,νValue,initialPositions]=
#+{displacmentU[#-dislocationCenter]/.{β-> βValue,ν-> νValue},0}&/@initialPositions

finalLattice[finalPositions_]:=finalLattice[finalPositions]=MapThread[{#1,Disk[#2,0.25]}&,{allColors,finalPositions}]

visualisationDislocationCoin2D=Manipulate[
DynamicModule[{finalPositions,finalLatticeMem,zoomImage,finalRef,indices,indicesFinal,finalPath,initialLattice,initialPositions},
initialPositions=Partition[Flatten@Table[{i*basis[[1]]+j*basis[[2]]}+{{0.25,0.25}},{i,-(size-1)/2,(size-1)/2},{j,-(size-1)/2,(size-1)/2}],2];
initialLattice=Graphics[{Gray,Disk[#,0.25]&/@initialPositions},PlotRange->{{-(size)/2-1,(size)/2+1},{-(size)/2-1,(size)/2}+1}];
(* Initial square path*)
referenceInfos=Nearest[initialPositions->{ "Element","Index"},dislocationCenter,4];
referencePoint=referenceInfos[[All,1]];
indices=referenceInfos[[All,2]];
path=Graphics[{Arrow[{#[[2]],#[[1]]}],
Arrow[{#[[1]],#[[3]]}],
Arrow[{#[[3]],#[[4]]}],
Arrow[{#[[4]],#[[2]]}]}]&;
(*Final path design *)
finalPath=Graphics[
{Arrow[{#[[2]],#[[1]]}],
Arrow[{#[[1]],#[[3]]}],
Arrow[{#[[3]],#[[4]]}],
Arrow[{#[[4]],#[[5]]}],
{Thick,Pink,Arrow[{#[[5]],#[[2]]}]}}]&;
indicesFinal=indices;
AppendTo[indicesFinal,59(*indicesFinal[[2]]-((size-1)/2)*)];

If[simplifiedModel,
finalPositions=finalPosSimplified[βValue,νValue,initialPositions],
finalPositions=finalPos[βValue,νValue,initialPositions]
];
	(*Position with displacement*)
finalLatticeMem=finalLattice[finalPositions];
finalRef=finalPositions[[#]]&/@indicesFinal;
(*Zoom*)
zoomImage=Grid[{{Show[Graphics[{GrayLevel[0.5],Disk[#,0.25]&/@initialPositions},PlotRange->{{-size/4,(size/4)-0.5},{-size/4,(size/4)-0.5}}],path[referencePoint]]
,Show[Graphics[finalLatticeMem,PlotRange->{{-size/4,(size/4)-0.5},{-size/4,(size/4)-0.5}}],finalPath[finalRef]]}}];
zoom1=If[burgerFlag,zoomImage,Graphics[{Transparent,Point[{0,0}]}]];
(*Final figure*)
Show[initialLattice,Graphics@finalLatticeMem,If[burgerFlag,finalPath[finalRef],Graphics[{Transparent,Point[{0,0}]}]],edgeDislocationLogo[{finalPositions[[72,1]],dislocationCenter[[2]]}]]],
(*Controls*)
Style["Dislocation coin",Bold],
Style["Description schématique sans déplacement vertical"],
{{simplifiedModel,True,"Modèle schématique"},{True,False}},
Style["Paramètres de dislocation"],
{{βValue,0.01},0.01,1,0.2},{{νValue,0.25},0.15,0.5,0.1},
Delimiter,
Style["Vecteur correspondant à la déformation élémentaire"],
{{burgerFlag,False,"Vecteur de Burgers"},{True,False}},
Dynamic@zoom1,
Delimiter,
ControlPlacement-> Left,LabelStyle->16
]

Visualisation en 3D avec plan de t and b

Visualisation

visualisationDislocationCoin3D= 
Manipulate[
DynamicModule[
{ν=0.25,initialPositions3D,finalPositions,initialLattice3D,finalPositions3D,finalLattice3D,planeStart,planeEnd,size=9,depth=4,basis,initialPositions},
basis=LatticeData["SquareLattice"]//Normal(*Lets make a simple 2D crystal structure*);
initialPositions=Partition[Flatten@Table[{i*basis[[1]]+j*basis[[2]]}+{{0.25,0.25}},{i,-(size)/2+2,(size)/2-2},{j,-(size)/2+2,(size)/2-2}],2];
(*initialPositions=Partition[Flatten@Table[{i*basis[[1]]+j*basis[[2]]},{i,1,size},{j,1,size}],2];*)
initialPositions3D=Partition[Flatten[Table[Flatten@{#[[1]],i,#[[2]]},{i,1,depth}]&/@initialPositions],3];(*add depth to 2D points from previous section*)
finalPositions=finalPos[β,ν,initialPositions];
finalPositions3D=Partition[Flatten[Table[Flatten@{#[[1]],i,#[[2]]},{i,1,depth}]&/@finalPositions],3];
(*Graphics*)
initialLattice3D=Graphics3D[Sphere[#,0.1]&/@initialPositions3D,ViewPoint->Front,Axes->True,AxesLabel->{x,y,z}];
finalLattice3D=Graphics3D[Sphere[#,0.1]&/@finalPositions3D,ViewPoint->Front,Boxed->False];
planeStart={finalPositions[[18,1]],0,0};
planeEnd={finalPositions[[18,1]],depth,0};
answer=If[answerFlag,Style["Le plan rouge est le plan de cisaillement\net le plan bleu représente la discontinuité\ndu réseau. Pour une dislocation coin ces\ndeux plans sont perpendiculaires."],Style[""]];
Show[
Graphics3D[{
{Opacity[0.5],Blue,HalfPlane[{planeStart,planeEnd},{0,0,1}]},
{Opacity[0.5],Red,HalfPlane[{{-3,0,0},{-3,depth,0}},{1,0,0}]}
},PlotRange->{{-2,size-6},{0,depth},{-2,size-6}}],
finalLattice3D]],
Style["Dislocation coin 3D",Bold],
{{β,0.15},0.01,1},
Delimiter, 
Style["Question",Bold],
Style["Que représentent les plans bleu et rouge? "],(*@instructor The question can be changed here*)
{{answerFlag,False,"Réponse"},{False,True}},
Dynamic@answer,
ControlPlacement->Left,LabelStyle->16
]

Energies (computed with Lennard-Jones potential) and strain field in 2D

Fonctions

particleForcesAndEnergiesCompiled= Compile[{{positions,_Real,2}}, 
Block[{distanceMatSq,distanceMatSixth, differenceMat,ret},
differenceMat = Outer
[Subtract,N[positions],N[positions],1] ;
distanceMatSq =Map[#.#&,differenceMat,{2}] + IdentityMatrix[Length[positions]];
distanceMatSixth= distanceMatSq^3;
Flatten[{(* Here it is where LJ comes into place -> *)
(*Forces*)Total[-12 differenceMat ( 1-distanceMatSixth)/distanceMatSq^7],
(*Energies*)Total[(1-2distanceMatSixth)/(distanceMatSixth^2)]
}]
]
];

particleForcesAndEnergies[positions_]:= Module[{res},
res = particleForcesAndEnergiesCompiled[positions];
{Partition[Take[res,2 Length[positions]],2],
Take[res,- Length[positions]]}
]

displayParticlesSmall[positions_, energies_,m_]:=Module[{},
Graphics[{
  Transpose[
   {
ColorData["Rainbow"][Sqrt@Clip[Rescale[#, {Min@energies, Max@energies}],{0,1}]] & /@ energies,
    Disk[#, 0.25] & /@ positions}
   ]},PlotRange->m,ImageSize->400]]

The dilatation is the trace of the strain tensor

strainMatrix[{dU_,dV_},{xVar_,yVar_}]:= 
Module[
{eps11,eps12,eps22},
eps11 = D[dU[{xVar,yVar}],xVar];
eps22 = D[dV[{xVar,yVar}],yVar];
eps12 =( D[dU[{xVar,yVar}],yVar] + D[dV[{xVar,yVar}],xVar])/2;
{
{eps11,eps12},
{eps12,eps22}
}
]

strainMatrixFormula=strainMatrix[{displacmentU,displacmentV},{x,y}];

Simplify[Tr[strainMatrixFormula]]

dilatation[β_,ν_]:=((y β (1-2 ν))/(2 π ((x^2)+(y^2)) (-1+ν)))

(*e.g.*)

ContourPlot[dilatation[1,1/3],{x,-7,7},{y,-7,7},PlotRange-> All,Contours->20,ColorFunctionScaling->False, ColorFunction->(ColorData["TemperatureMap"][(0.05  + #)/.1]&),BaseStyle-> Directive[Opacity[0.5]],Mesh->None,ImageSize->Large]

Visualisation avec l’energie des atomes

visualisationEdgeDislocation2DEnergy=
Manipulate[
DynamicModule[{finalPositions,finalLatticeMem},
background=Graphics[{Transparent,Rectangle[{-(size-1)/2,(size-1)/2}]},ImageSize->Large];
initialPositions=Partition[Flatten@Table[{i*basis[[1]]+j*basis[[2]]}+{{0.25,0.25}},{i,-(size-1)/2,(size-1)/2},{j,-(size-1)/2,(size-1)/2}],2];
strainfield=ContourPlot[dilatation[βValue,1/3],{x,-7,7},{y,-7,7},PlotRange-> All,Contours->Range[-.05,.05,.01],ContourLabels-> True,ColorFunctionScaling->False, ColorFunction->(ColorData["TemperatureMap"][(0.05  + #)/.1]&),ClippingStyle->{Blue, Red},Method->{"TransparentPolygonMesh"-> True},BaseStyle-> Directive[Opacity[opacityValue]],ImageSize->Large];
strainFieldContour=If[strainFieldFlag,strainfield,background];

finalPositions=finalPos[βValue,νValue,initialPositions];
(*Position with displacement*)
{forcesInitiales,energiesInitiales}=particleForcesAndEnergies[finalPositions];
{forces,energies}=particleForcesAndEnergies[finalPositions];
finalLatticeMem=displayParticlesSmall[finalPositions,energies,All];
Overlay[{Show[finalLatticeMem,ImageSize->Large,Frame->True],strainFieldContour}]],
(*Controls*)
Style["Dislocation coin",Bold],
Style["Paramètres de dislocation"],
{{βValue,0.01},0.01,1,0.2},
{{νValue,0.25},0.15,0.5,0.1},
{{strainFieldFlag,False,"Champ de déformation"},{True,False}},
Style["Les contours bleu indiquent la compression, le rouge la tension. "],
{{opacityValue,0.5,"Opacité"},0.05,1,0.2},
Delimiter, 
Style["L'énergie des atomes est calculée avec le potentiel de Lennard-Jones. Voir le Notebook correspondant."],
ControlPlacement-> Left,LabelStyle->16
];

Démonstration  : Défaut linéaire dislocation vis

visualisation in 3D with t and b

Dans le cas d’une dislocation vis le deplacement est uniquement dans la direction verticale:

displacmentZ[β_,{x_,y_,z_}]:=(β/(2 π))(ArcTan[x,y])

basis=LatticeData["SquareLattice"]//Normal(*Lets make a simple 2D crystal structure*);

Clear@finalPosScrew

(*Functions final position and final lattice with β and ν values*)
finalPosScrew[βValue_,initialPositions_]:=
finalPosScrew[βValue,initialPositions]=
#+{0,0,displacmentZ[βValue,#]}&/@initialPositions

visualisationDislocationVis3D=Manipulate[
DynamicModule[{background,finalPositions,finalLatticeMem,size,initialPositions,initialPositions3D,allColors3D,finalLattice3D,refPathPositions,refPath,finalPath,finalPathPositions,finalPathCompletePositions,finalPathComplete,burgerVector},
size=6;
background=Graphics3D[{Transparent,Sphere[{0,0,0},0.2]},Boxed->False];
initialPositions=Partition[Flatten@Table[{{0.25,0.25}}+{i*basis[[1]]+j*basis[[2]]},{i,-size/2,size/2},{j,-size/2,size/2}],2];
initialPositions3D=Partition[Flatten[Table[Flatten@{#[[1]],i,#[[2]]},{i,-size/2,size/2}]&/@initialPositions],3];
allColors3D=ColorData["Rainbow"][Rescale[#[[3]],{Min@initialPositions3D[[All,3]],Max@initialPositions3D[[All,3]]},{0,1}]]&/@initialPositions3D;
finalLattice3D[finalPositions_]:=finalLattice[finalPositions]=MapThread[{#1,Sphere[#2,0.25]}&,{allColors3D,finalPositions}];
finalPositions=N@finalPosScrew[βValue,initialPositions3D];
	(*Position with displacement*)
finalLatticeMem=finalLattice3D[finalPositions];
(*Path *)
refPathPositions=initialPositions3D[[#]]&/@{192,241,242,243,194,145,144,143,192};
refPath=If[initialPathFlag,Graphics3D[{White,Tube[{refPathPositions},0.1]}],background];
finalPathPositions=finalPositions[[#]]&/@{137,143,192,241,242,243,194,145,144};
finalPath=If[finalPathFlag,Graphics3D[{Black,Tube[{finalPathPositions},0.1]}],background];
finalPathCompletePositions=finalPositions[[#]]&/@{171,220,221,222,173,124,123,129,178,227,228,229,180,131,130,136,185,234,235,236,187,138,137,143,192,241,242,243,194,145,144};
finalPathComplete=If[finalPathFlag,Graphics3D[{Black,Tube[{finalPathCompletePositions},0.1]}],background];
burgerVector=If[burgerFlag,Graphics3D[{Black,Arrow[Tube[{finalPositions[[137]],finalPositions[[144]]},0.05]]}],background];
(*Preset viewpoint*)
side1={-10,-0.5,0.5};
side2={1.75,-10,4};
side3={-12,-12,1};
(*Zoom*)
zoomVis=If[zoomFlag,Show[Graphics3D@finalLatticeMem, finalPathComplete,burgerVector,PlotRange->{{-(size/2)+2,(size/2)-1.5},{-(size/2)+1.5,(size/2)-1.5},{0,size/2+1}}],background];

(*Final figure*)
Show[Graphics3D@finalLatticeMem,refPath, finalPath,burgerVector,ViewPoint->viewpointValue]],
(*Controls*)
Style["Dislocation vis",Bold],
Style["Utiliser le slider pour créer la dislocation.\nEnsuite utiliser les checkboxs pour visualiser la construction\ndu vecteur de Burgers. "],

Style["Paramètres de dislocation"],
{{βValue,0.01,"Magnitude du vecteur de Burgers"},0.01,1,0.2},
Delimiter,
{{viewpointValue,side2},{ side2-> "Front view",side1-> "Side view",side3-> "Corner view"}},
Delimiter,
Style["Construction du vecteur de Burgers"],
{{initialPathFlag,False,"Alignement initial"},{True,False}},
{{finalPathFlag,False,"Alignement après déformation"},{True,False}},
{{burgerFlag,False,"Vecteur de Burgers"},{True,False}},
Delimiter,
{{zoomFlag,False,"Zoom"},{True,False}},
Dynamic@zoomVis,
ControlPlacement-> Left,LabelStyle->16
]

Visualisation in 3 D avec plan de t et b

visualisationDislocationVis3DPlans=Manipulate[
DynamicModule[{background,initialPositions,initialPositions3D,finalPositions,finalLatticeMem,planeStart,planeStartt,planeEndt,planeShear,allColors3D,finalLattice3D,size=5,burgerVector,planeShearTwo},
(*Position with displacement*)
background=Graphics3D[{Transparent,Sphere[{0,0,0},0.2]},Boxed->False];
initialPositions=Partition[Flatten@Table[{{0.25,0.25}}+{i*basis[[1]]+j*basis[[2]]},{i,-size/2,size/2},{j,-size/2,size/2}],2];
initialPositions3D=Partition[Flatten[Table[Flatten@{#[[1]],i,#[[2]]},{i,-size/2,size/2}]&/@initialPositions],3];
allColors3D=ColorData["Rainbow"][Rescale[#[[3]],{Min@initialPositions3D[[All,3]],Max@initialPositions3D[[All,3]]},{0,1}]]&/@initialPositions3D;
finalLattice3D[finalPositions_]:=finalLattice[finalPositions]=MapThread[{#1,Sphere[#2,0.25]}&,{allColors3D,finalPositions}];
finalPositions=N@finalPosScrew[βValue,initialPositions3D];
	finalLatticeMem=finalLattice3D[finalPositions];
burgerVector=If[burgerFlag,Graphics3D[{Black,Arrow[Tube[{finalPositions[[137]],finalPositions[[144]]},0.05]]}],background];
(*Plane*)
planeStartt=initialPositions3D[[34]]+{0,-0.5,0.};
planeEndt=initialPositions3D[[214]]+{0,-0.5,0.};
(*vector=;*)
planeShear=Graphics3D[{Opacity[0.5],Blue,HalfPlane[{planeStartt,planeEndt},{0,0,-1.1}]}];
planeShearTwo=Graphics3D[{Opacity[0.5],Red,HalfPlane[{planeStartt+{0,-0.05,0.},planeEndt+{0,-0.05,0.}},{0,0,-0.5}]}];
(*Final figure*)
Show[Graphics3D@finalLatticeMem,planeShear, planeShearTwo,burgerVector,ViewPoint->{10,2,4}]],
(*Controls*)
Style["Dislocation vis",Bold],
Style["Le plan rouge est le plan de cisaillement et le plan bleu représente la discontinuité du réseau.\n Pour une dislocation coin ces deux plans sont perpendiculaires.\n Les plans sont légérement décalés pour une meilleure visualisation."],
Style["Paramètres de dislocation"],
{{βValue,0.01,"Magnitude du vecteur de Burgers"},0.01,1,0.2},
{{burgerFlag,False,"Vecteur de Burgers"},{True,False}},
ControlPlacement-> Left,LabelStyle->16
];

Excess of energy

Lennard - Jones 3 D

particleEnergies3D[positions_]:= 
Module[{differenceMat,invDistanceMatSixth},
differenceMat = DistanceMatrix[N@positions,DistanceFunction-> SquaredEuclideanDistance] + IdentityMatrix[Length[positions]];
invDistanceMatSixth = 1/differenceMat^3;
(Total[invDistanceMatSixth(invDistanceMatSixth-2)] + 1)/2
]

displayParticles3D[positions_, energies_,m_(*min_:Min@energies,max_:Max@energies*)]:=Module[{},
Graphics3D[{
  Transpose[
   {ColorData["Rainbow"][Sqrt@Clip[Rescale[#, {Min@energies,Max@energies}],{0,1}]] & /@ energies,
    Sphere[#, 0.25] & /@ positions}
   ]},PlotRange->m,ImageSize->400]]

displayParticles3DMinMax[positions_, energies_,m_,min_,max_]:=Module[{},
Graphics3D[{
  Transpose[
   {ColorData["Rainbow"][Sqrt@Clip[Rescale[#, {min,max}],{0,1}]] & /@ energies,
    Sphere[#, 0.25] & /@ positions}
   ]},PlotRange->m,ImageSize->400]]

visualisationDislocationVis3DEnergies=
Manipulate[
DynamicModule[{finalPositions,initialPositions,initialPositions3D,finalLatticeMem,energiesInitiales,energies,atomesZoom,(*energiesZoom,*)zoomLatticeMem(*,zoom*)},
initialPositions=Partition[Flatten@Table[{{0.25,0.25}}+{i*basis[[1]]+j*basis[[2]]},{i,-size/2,size/2},{j,-size/2,size/2}],2];
initialPositions3D=Partition[Flatten[Table[Flatten@{#[[1]],i,#[[2]]},{i,-size/2,size/2}]&/@initialPositions],3];
(*Position with displacement*)
finalPositions=N@finalPosScrew[βValue,initialPositions3D];
(*Energies*)
energiesInitiales=particleEnergies3D[initialPositions3D];
energies=particleEnergies3D[finalPositions];
finalLatticeMem=displayParticles3D[finalPositions,energies,All];
(*Preset viewpoint*)
side1={-10,-0.5,0.5};
side2={1.75,-10,4};
side3={-12,-12,1};
(*Zoom*)
atomesZoom=Cases[initialPositions3D,{x_,y_,z_}/;(Abs[x] < 1.5&& Abs[y] < 2 && Abs[z] < 1.75 )];
energiesZoom=particleEnergies3D[atomesZoom];
{min,max}={Min@energiesZoom,Max@energiesZoom};
zoomLatticeMem=displayParticles3DMinMax[finalPositions,energies,All,min,max];
zoom=If[zoomFlag,Show[zoomLatticeMem,PlotRange->{{-1.5,1.5},{-1.5,1.5},All},ImageSize->Medium],background];
(*Final figure*)
Show[finalLatticeMem,ViewPoint->viewpointValue]],
(*Controls*)
Style["Dislocation vis",Bold],
Style["Utiliser le slider pour créer la dislocation.\nLa couleur indique l'énergie des atomes.\nLe zoom permet de visualiser l'augmentation d'énergie autour de la dislocation. "],
Delimiter,
Style["Paramètres de dislocation"],
{{βValue,1,"Magnitude du vecteur de Burgers"},0.01,1,0.2},
Delimiter,
{{viewpointValue,side2,"Point de vue"},{ side2-> "Front view",side1-> "Side view",side3-> "Corner view"}},
Delimiter,
{{zoomFlag,False,"Zoom"},{True,False}},
Dynamic@zoom,
ControlPlacement-> Left,LabelStyle->16
]

All

CreateDocument[
Manipulate[
Which[
Select==1,lacuneVisualisation,
Select==2,substitutionnelVisualisation,
Select==3,interstitielVisualisation,
Select==4,visualisationDislocationCoin2D,
Select==5,visualisationDislocationCoin3D,
Select==6,visualisationEdgeDislocation2DEnergy,
Select==7,visualisationDislocationVis3D,
Select==8,visualisationDislocationVis3DPlans,
Select==9,visualisationDislocationVis3DEnergies],
{{Select,1},
{1-> "Défaut ponctuel: Lacune",
2-> "Défaut ponctuel: Substitutionel",
3-> "Défaut ponctuel: Interstitiel",
4 -> "Défaut linéaire : Dislocation coin 2D",
5 -> "Défaut linéaire : Dislocation coin 3D",
6-> "Energies et champ de deformation : Dislocation coin 2D",
7 -> "Défaut linéaire : Dislocation vis 3D",
8 -> "Défaut linéaire : Dislocation vis 3D avec plans",
9 -> "Energies: Dislocation vis 3D"
}},LabelStyle->{16,Bold}]
,WindowSize->Full
(*Commenter le (*,WindowSize->Full*) pour faire apparaître la fenêtre dans le même bureau*)];
(NotebookObjectUnsaved[t3vrz_shm, , FrontEndObject[LinkObject["t3vrz_shm", 3, 1]], 23, "Untitled-2"])