myLoading.m
This pakcage allows to load mesh and material properties, set boundary conditions, and initialize the AceFEM environment.
This package provide also the material coefficients:
loadMATXcoeff[]:=Module[{c1MATX, c2MATX, c3MATX},
c1MATX = 2.35 10^4;
c2MATX = 1.26 10^5;
c3MATX = 1.12 10^5;
{c1MATX, c2MATX, c3MATX}
]
loadCALCcoeff[]:=Module[{c1, c2, c3},
c1 = 3.021 10^5;
c2 = -2.28 10^5;
c3 = 2.61 10^5;
{c1, c2, c3}
]
loadFIBRcoeff[]:=Module[{c1, c2, c3},
c1 = 73600;
c2 = 0;
c3 = 0;
{c1, c2, c3}
]
loadLRNCcoeff[]:=Module[{c1, c2, c3},
c1 = 2.96 10^4;
c2 = -3.32 10^4;
c3 = 1.285 10^5;
{c1, c2, c3}
]
The setMaterialsNew[] functions allows for setting the material properties for each element using the provided material ratios and fitting new coefficients based on the weighted average of the material responses.
Warning
Each material InterpolatingFunction contains a binary repsentation of each material distribution (0 no material, 1 material).
The material response is based on the weighted average of the material responses, not on the coefficient interpolation.
Interpolating the coefficients may lead to non-admissible strain energy density.
The findMaterialFunction extract the exact ratio of the materials for each element, based on the matxTruthTable. For each element, the ratio is an association strucutre like:

where
are the ratio of the materials in the element.
The stress response reads:

based on the Yeoh strain energy function uniaxial response:

where
is the uniaxial stretch and
are the material coefficients.
The fitting is implemented as follows:
setMaterialsNew[elementMaterialRatios_]:=Module[{centers, mats, elementIndex, elementNodes, center, newCenters,yeohFit,data,αM,αF,αL,αC,nEle},
centers = {};
elementIndex = AceFEM`SMTElementData["ElemIndex"][[Flatten@Position[AceFEM`SMTElementData["Domain"], "Ωc"]]];
elementNodes = AceFEM`SMTElementData["Nodes"][[Flatten@Position[AceFEM`SMTElementData["Domain"], "Ωc"]]];
centers = Mean[AceFEM`SMTNodeData[elementNodes[[1]], "X"]];
αM=#["MATX"]&/@elementMaterialRatios[[All]];
αF=#["FIBR"]&/@elementMaterialRatios[[All]];
αC=#["CALC"]&/@elementMaterialRatios[[All]];
αL=#["LRNC"]&/@elementMaterialRatios[[All]];
p = PrintTemporary[ProgressIndicator[0]];
nEle=Length[elementIndex];
yeohFit=ConstantArray[AceFEM`SMTElementData[1, "Data"],nEle];(*create a constant array with the correct shape*)
Do[
data=Table[{λ,response[λ,αM[[i]],αF[[i]],αL[[i]],αC[[i]]]},{λ,1,1.5,0.01}];
yeohFit[[i]]={Subscript[\[FormalC], 1],Subscript[\[FormalC], 2],Subscript[\[FormalC], 3]}/.FindFit[data,{σuni[λ,{Subscript[\[FormalC], 1],Subscript[\[FormalC], 2],Subscript[\[FormalC], 3]}]},{Subscript[\[FormalC], 1],Subscript[\[FormalC], 2],Subscript[\[FormalC], 3]},λ];
If[Mod[i, 300] == 0,
NotebookDelete[p];
p = PrintTemporary[ProgressIndicator[i/ Length[elementIndex]]];
];
, {i, 1, nEle}];
AceFEM`SMTElementData[Range[nEle], "Data", yeohFit];
];
Warning
The following description is partially AI generated, it might be incomplete or incorrect.
- loadMesh[folderPath]()
Loads the mesh from the specified folder path and returns the nodes and connectivity.
- Parameters:
folderPath (String) – Path to the folder containing the mesh files.
- Returns:
A list containing nodes, connectivity, lumen boundary, and fixed boundary.
- Return type:
List
Usage Example:
loadMesh["/path/to/folder"]
- materialInterp[paths]()
Returns a list of interpolating functions for the material properties.
- Parameters:
paths (List of Strings) – List of file paths containing material property data.
- Returns:
List of interpolating functions.
- Return type:
List of InterpolatingFunction
Usage Example:
materialInterp[{"path/to/file1.txt", "path/to/file2.txt"}]
- updateElements[elements]()
Updates the elements in the Common/Elements folder with those in the current folder.
- Parameters:
elements (List of Strings) – List of element names to be updated.
- Returns:
None
Usage Example:
updateElements[{"Element1", "Element2"}]
- setMaterials[materialProperties, elementNodes]()
Sets the material properties of the elements in the provided element nodes.
- Parameters:
materialProperties (List of InterpolatingFunction) – Interpolating functions for the material properties.
elementNodes (List) – Nodes of the elements for which the materials are to be set.
- Returns:
None
Usage Example:
setMaterials[materialProps, elementNodes]
- setMaterialsV2[matsPath]()
Sets the material properties of the elements in the domain using data from specified paths.
- Parameters:
matsPath (List of Strings) – List of paths to material property files.
- Returns:
None
Usage Example:
setMaterialsV2[{"path/to/mat1.txt", "path/to/mat2.txt"}]
- fastFixedBoundary[fixed, threshold]()
Sets the fixed boundary conditions in the Z direction.
- Parameters:
fixed (List) – List of fixed nodes.
threshold (Number) – Threshold value for setting the boundary conditions.
- Returns:
None
Usage Example:
fastFixedBoundary[fixedNodes, 0.01]
- initializeAceFEM[nodes, connectivity, lumen]()
Initializes the AceFEM environment with the specified nodes, connectivity, and lumen boundary.
- Parameters:
nodes (List) – Node coordinates.
connectivity (List) – Connectivity information for the elements.
lumen (List) – Lumen boundary nodes.
- Returns:
None
Usage Example:
initializeAceFEM[nodes, connectivity, lumen]
- loadMATXcoeff()
Returns the material coefficients for the MATX material.
- Returns:
A list of coefficients for the MATX material.
- Return type:
List of Numbers
Usage Example:
loadMATXcoeff[]
- loadCALCcoeff()
Returns the material coefficients for the CALC material.
- Returns:
A list of coefficients for the CALC material.
- Return type:
List of Numbers
Usage Example:
loadCALCcoeff[]
- loadFIBRcoeff()
Returns the material coefficients for the FIBR material.
- Returns:
A list of coefficients for the FIBR material.
- Return type:
List of Numbers
Usage Example:
loadFIBRcoeff[]
- loadLRNCcoeff()
Returns the material coefficients for the LRNC material.
- Returns:
A list of coefficients for the LRNC material.
- Return type:
List of Numbers
Usage Example:
loadLRNCcoeff[]
- setMaterialsV3[matsPath, materialProperties]()
Sets the material properties of the elements in the domain using data from specified paths and properties.
- Parameters:
matsPath (List of Strings) – List of paths to material property files.
materialProperties (List of InterpolatingFunction) – Interpolating functions for the material properties.
- Returns:
None
Usage Example:
setMaterialsV3[{"path/to/mat1.txt", "path/to/mat2.txt"}, materialProps]
- materialTruthMask[paths, coeff, tolerance]()
Generates a material mask using interpolating functions with tolerance.
- Parameters:
paths (List of Strings) – List of file paths for material properties.
coeff (List of Numbers) – Coefficients used in the interpolating functions.
tolerance (Number) – Tolerance for perturbation in the interpolation.
- Returns:
A dictionary with keys as material names and values as interpolating functions.
- Return type:
Association
Usage Example:
materialTruthMask[{"path/to/file1.txt"}, {coeff1, coeff2}, 0.1]
- setMaterialsNew[elementMaterialRatios]()
Sets the material properties for each element using the provided material ratios.
- Parameters:
elementMaterialRatios (List of Associations) – List of associations with material ratios for each element.
- Returns:
None
Usage Example:
setMaterialsNew[materialRatios]
- findMaterialRatio[materialProperties]()
Finds the material ratios for each element based on the provided material properties.
- Parameters:
materialProperties (List of) – Interpolating functions for the material properties.