├── ElementConnectivity.m ├── intarclength.m ├── .gitattributes ├── .gitignore ├── NoNodalForces.m ├── leafgrads.m ├── ElementData.m ├── PrintANCFOutput.m └── ME_396_PreSAMS_1.m /ElementConnectivity.m: -------------------------------------------------------------------------------- 1 | function [Connectivity] = ElementConnectivity(); 2 | 3 | row = 1; 4 | E = []; 5 | F = []; 6 | 7 | for j = 16:-2:1 % For 8 leafs with 17 nodes for first leaf, reduced by 2 nodes for successive leaf 8 | 9 | for i=1:j 10 | E = [(row) (row+1)]; 11 | F = [F;E]; 12 | row = row+1; 13 | end 14 | 15 | row = row+1; 16 | end 17 | 18 | F 19 | Connectivity = F; -------------------------------------------------------------------------------- /intarclength.m: -------------------------------------------------------------------------------- 1 | function [dxArcLength]=intarclength(f,h) 2 | 3 | row = 1; 4 | [m,n] = size(h); 5 | A = []; 6 | 7 | fprime = diff(f); 8 | arclength = sqrt(1+fprime^2); 9 | 10 | 11 | for j = 16:-2:1 % For 8 leafs with 17 nodes for first leaf, reduced by 2 nodes for successive leaf 12 | 13 | for i=1:j 14 | s = integral(matlabFunction(arclength),h(row),h(row+1)); 15 | A = [A;s]; % Cocatenate results 16 | row = row+1; 17 | end 18 | row = row+1; 19 | end 20 | 21 | dxArcLength = A; 22 | 23 | %disp(A) 24 | 25 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # ========================= 18 | # Operating System Files 19 | # ========================= 20 | 21 | # OSX 22 | # ========================= 23 | 24 | .DS_Store 25 | .AppleDouble 26 | .LSOverride 27 | 28 | # Icon must end with two \r 29 | Icon 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear on external disk 35 | .Spotlight-V100 36 | .Trashes 37 | 38 | # Directories potentially created on remote AFP share 39 | .AppleDB 40 | .AppleDesktop 41 | Network Trash Folder 42 | Temporary Items 43 | .apdisk 44 | -------------------------------------------------------------------------------- /NoNodalForces.m: -------------------------------------------------------------------------------- 1 | function [ NodalForces ] = NoNodalForces( ElementType,NumNodes,NumNodesPerElement,NodeNumbers ) 2 | %NoNodalForces: Generates nodal force section of PreSAMS ANCF 3 | % This function generates an array for printing to the PreSAMS file 4 | % making the assumption that there are no nodal forces. 5 | 6 | if ElementType == 2 ... 7 | || ElementType == 6 ... 8 | || ElementType == 7 9 | NodalForceZeros = zeros(NumNodes, 3*NumNodesPerElement); 10 | NodalForces = horzcat(NodeNumbers, NodalForceZeros); 11 | elseif ElementType == 5 12 | NodalForceZeros = zeros(NumNodes, 6*NumNodesPerElement); 13 | NodalForces = horzcat(NodeNumbers, NodalForceZeros); 14 | elseif ElementType == 8 15 | NodalForceZeros = zeros(NumNodes, 9); 16 | NodalForces = horzcat(NodeNumbers, NodalForceZeros); 17 | else 18 | display(' ') 19 | display('ERROR: Element Type not currently suported! error generated in NoNodalForces.m.') 20 | display(' ') 21 | end 22 | 23 | end 24 | 25 | -------------------------------------------------------------------------------- /leafgrads.m: -------------------------------------------------------------------------------- 1 | % f = function of z >Example - 0.0073*x^2 2 | % data = coordinates of each node > [x z] 3 | 4 | 5 | %%Input ------------------------------------------------------------------- 6 | 7 | function [PositionVectorGradient] = leafgrads(f,data); 8 | 9 | % tic % Start clock 10 | 11 | [m,n] = size(data); % Pull size of data matrix 12 | fprime = diff(f); % Differentiate function 13 | row = 1; % Start row at 1, which will work through 14 | 15 | A = []; % Initialize empty matrix A, which will hold our results 16 | 17 | for i=1:m 18 | 19 | theta = atan(feval(inline(fprime),data(row,1))); % Find theta using the arctan of the derivative of f, evaulated at x_i 20 | atrans = [cos(theta) -sin(theta); sin(theta) cos(theta)]; % Calculate tranformation matrix 21 | 22 | rx = atrans*[1;0]; % Generate R_j,x 23 | rz = [0 -1;1 0]*rx; % Generate R_j,z, assuming orthonormal to R_j,x 24 | 25 | B = [rx(1) 0 rx(2) 0 1 0 rz(1) 0 rz(2)]; % Build nodal coordinates at node 26 | A = [A;B]; % Cocatenate nodal coordinates to previous 27 | 28 | row = row+1; % Advance to next node 29 | 30 | end 31 | 32 | row = 1; 33 | D = []; 34 | 35 | for i=16:-2:1 36 | 37 | for j=1:i 38 | 39 | C = [A(row,:) A((row+1),:)]; 40 | D = [D;C]; 41 | row = row+1; 42 | 43 | end 44 | 45 | row = row+1; 46 | 47 | end 48 | 49 | PositionVectorGradient = D; 50 | 51 | 52 | 53 | % toc %Display clock 54 | 55 | % disp(' Node R_j,xx R_j,xy R_j,xz R_j,yx R_j,yy R_j,yz R_j,zx R_j,zy R_j,zz ') 56 | % disp(' ') 57 | % disp(A) 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /ElementData.m: -------------------------------------------------------------------------------- 1 | function [ NumNodesPerElement , GradsPerElement ] = ElementData( ElementType ) 2 | %ElementData: Returns the number of nodes and gradients for a given 3 | %ANCF element. 4 | % 5 | %Element Types 6 | % 1 = 2-D Beam(Euler) NodesPerElement=2, GradsPerElement=4 7 | % 2 = 2-D Beam(Shear) NodesPerElement=2, GradsPerElement=8 8 | % 3 = 2-D Rectangular NodesPerElement=4, GradsPerElement=16 9 | % 4 = 2-D Triangular NodesPerElement=3, GradsPerElement=12 10 | % 5 = 3-D Beam NodesPerElement=2, GradsPerElement=18 11 | % 6 = Plate 1 NodesPerElement=4, GradsPerElement=36 12 | % 7 = Plate 2 NodesPerElement=4, GradsPerElement=36 13 | % 8 = Thin Plate NodesPerElement=4, GradsPerElement=24 14 | % 9 = Cable Element NodesPerElement=2, GradsPerElement=6 15 | % 10 = Solid Element NodesPerElement=8, GradsPerElement=72 16 | % 11 = ANCF BSpline Plate NodesPerElement=4, GradsPerElement=24 17 | % 12 = Higher Order Beam NodesPerElement=2, GradsPerElement=18 18 | 19 | %% Nodes per element------------------------------------------------------- 20 | if ElementType == 1 ... 21 | || ElementType == 2 ... 22 | || ElementType == 5 ... 23 | || ElementType == 9 ... 24 | || ElementType == 12 25 | NumNodesPerElement = 2; 26 | 27 | elseif ElementType == 3 ... 28 | || ElementType == 6 ... 29 | || ElementType == 7 ... 30 | || ElementType == 8 ... 31 | || ElementType == 11 32 | NumNodesPerElement = 4; 33 | 34 | elseif ElementType == 4 35 | NumNodesPerElement = 3; 36 | 37 | elseif ElementType == 10 38 | NumNodesPerElement = 8; 39 | 40 | else 41 | fprintf(fid, 'ElementType selected not within range. \r\n error generated in ElementData.m'); 42 | end 43 | 44 | 45 | %% Gradients per element--------------------------------------------------- 46 | if ElementType == 1 47 | GradsPerElement = 4; 48 | 49 | elseif ElementType == 2 50 | GradsPerElement = 8; 51 | 52 | elseif ElementType == 3 53 | GradsPerElement = 16; 54 | 55 | elseif ElementType == 4 ... 56 | || ElementType == 12 57 | GradsPerElement = 12; 58 | 59 | elseif ElementType == 5 60 | GradsPerElement = 18; 61 | 62 | elseif ElementType == 6 ... 63 | || ElementType == 7 64 | GradsPerElement = 36; 65 | 66 | elseif ElementType == 8 ... 67 | || ElementType == 11 68 | GradsPerElement = 24; 69 | 70 | elseif ElementType == 9 71 | GradsPerElement = 6; 72 | 73 | elseif ElementType == 10 74 | GradsPerElement = 72; 75 | 76 | end 77 | 78 | end 79 | 80 | -------------------------------------------------------------------------------- /PrintANCFOutput.m: -------------------------------------------------------------------------------- 1 | function [ ] = PrintANCFOutput(SAMSMode , AnalysisType , NumModels , ... 2 | ModelDimensions, ElementConnectivity, ... 3 | NodeLocations, ElementProperties, NodalForces, ... 4 | PositionVectorGradient, ElementType, PreSAMS_File_Name) 5 | %PrintANCFOutput: Prints PreSAMS ANCF file 6 | % Detailed explanation goes here 7 | 8 | 9 | % open a file for writing 10 | fid = fopen(PreSAMS_File_Name, 'w'); % Location of the PreSAMS file used 11 | 12 | % Print PreSAMS File 13 | fprintf(fid, 'SAMS-Mode \r\n'); 14 | fprintf(fid, '%2.0f \r\n', SAMSMode); 15 | fprintf(fid, '=======================================================================\r\n'); 16 | fprintf(fid, '%s',PreSAMS_File_Name); 17 | fprintf(fid, '\r\n'); 18 | fprintf(fid, '=======================================================================\r\n'); 19 | fprintf(fid, 'Analysis-Type\r\n'); 20 | fprintf(fid, '%2.0f \r\n', AnalysisType); 21 | fprintf(fid, '=======================================================================\r\n'); 22 | fprintf(fid, 'Number-of-Models\r\n'); 23 | fprintf(fid, '%2.0f \r\n', NumModels); 24 | fprintf(fid, '=======================================================================\r\n'); 25 | fprintf(fid, '=======================================================================\r\n'); 26 | fprintf(fid, 'Model_#_1_Name\r\n'); 27 | fprintf(fid, 'Model_#_1\r\n'); 28 | fprintf(fid, '=======================================================================\r\n'); 29 | fprintf(fid, 'Model-Dimension\r\n'); 30 | fprintf(fid, '%2d %12d %13d %14d %12d %13d %13d\r\n', ModelDimensions); 31 | fprintf(fid, '=======================================================================\r\n'); 32 | fprintf(fid, 'Element-Connectivity\r\n'); 33 | fprintf(fid, '%1.0f\t%1.0f\t %1.0f \r\n', ElementConnectivity'); 34 | fprintf(fid, '=======================================================================\r\n'); 35 | fprintf(fid, 'Nodal-Locations\r\n'); 36 | 37 | if ElementType == 1 ... % 2D element 38 | || ElementType == 2 39 | fprintf(fid, '%1d\t%1.0f\t %1.0f \r\n', NodeLocations'); 40 | end 41 | if ElementType == 5 % 3D element 42 | fprintf(fid, '%d\t%f\t%f\t%f\t \r\n', NodeLocations'); 43 | end 44 | 45 | fprintf(fid, '=======================================================================\r\n'); 46 | fprintf(fid, 'Element-Properties\r\n'); 47 | fprintf(fid, '%1d\t%1.0f\t%f\t%f\t%f\t%1.0f\t%1.0f\t%f\t%1d\t%1d\t%1d\t%1d\t%1d\t%1d \r\n', ElementProperties'); 48 | fprintf(fid, '=======================================================================\r\n'); 49 | fprintf(fid, 'Nodal-Forces\r\n'); % Number of forces = number of coordinates 50 | 51 | if ElementType == 2 ... 52 | || ElementType == 6 ... 53 | || ElementType == 7 54 | fprintf(fid, '%1.0f\t%1.0f\t%1.0f\t%1.0f\t%1.0f\t%1.0f\t %1.0f \r\n', NodalForces'); 55 | elseif ElementType == 5 56 | fprintf(fid, '%1.0f\t%1.0f\t%1.0f\t%1.0f\t%1.0f\t%1.0f\t%1.0f\t%1.0f\t%1.0f\t%1.0f\t%1.0f\t%1.0f\t %1.0f \r\n', NodalForces'); 57 | elseif ElementType == 8 58 | fprintf(fid, '%1.0f\t%1.0f\t%1.0f\t%1.0f\t%1.0f\t%1.0f\t%1.0f\t%1.0f\t%1.0f\t %1.0f \r\n', NodalForces'); 59 | end 60 | 61 | fprintf(fid, '=======================================================================\r\n'); 62 | fprintf(fid, 'Element-Position-Vector-Gradients\r\n'); 63 | 64 | if ElementType == 2 65 | fprintf(fid, '%1d\t%d\t%d\t%d\t%1.0f\t%1.0f\t%1d\t%1d\t %1d \r\n', PositionVectorGradient'); 66 | elseif ElementType == 5 67 | fprintf(fid, '%1d\t%f\t%f\t%f\t%f\t%f\t%1f\t%1f\t%1f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t %1f \r\n', PositionVectorGradient'); 68 | end 69 | fprintf(fid, '=======================================================================\r\n'); 70 | fprintf(fid, ' 1000 0 \r\n'); 71 | fprintf(fid, 'End-of-Model-1-data\r\n'); 72 | fclose(fid); 73 | 74 | 75 | 76 | end 77 | 78 | -------------------------------------------------------------------------------- /ME_396_PreSAMS_1.m: -------------------------------------------------------------------------------- 1 | 2 | 3 | % clear all ; % clear memory 4 | % close all ; % close any open figures 5 | drawnow ; % update screen now 6 | clc ; % clear screen 7 | 8 | display('** Processing Data **') ; 9 | display(' ') ; 10 | tic 11 | 12 | % Enter the directory and file name of your PreSAMS input file 13 | PreSAMS_File_Name = 'C:\Users\Tim\Desktop\ME_396_PreSAMS_Temp.sam'; 14 | 15 | %% PreSAMS Models---------------------------------------------------------- 16 | 17 | % See SamsHelp page 526-257 18 | 19 | SAMSMode = 2; % 2 = PreSAMS (Should always == 2 !!!) 20 | AnalysisType = 2; % 1=FFR, 2=ANCF, 3=External Data, 4=ANCF Surface Geometry (Only AnalysisType==2 supported at this time) 21 | NumModels = 1; % (for this script NumModels = 1 only!!) 22 | 23 | % ENTER DATA HERE----------------------- 24 | 25 | NumElements = 72; % Enter the number of elements in your model 26 | NumNodes = 80; % Enter the number of nodes in your model 27 | %--------------------------------------- 28 | 29 | ElementType = 5; %Element type should be 5 (3D Beam) 30 | NCKNOT = 0; %Contiunuity (for this script NCKNOT = 0 only!!) 31 | Cholesky = 0; %Cholesky Transformantion Matrix (leave as 0) 32 | ElementTrans = 1; % 0=Print, 1=No Print 33 | 34 | ElementNumbers = 1:NumElements; % This is used later to fill the first col of some of the sections 35 | ElementNumbers = ElementNumbers'; 36 | NodeNumbers = 1:NumNodes; % This is used later to fill the first col of some of the sections 37 | NodeNumbers = NodeNumbers'; 38 | 39 | [NumNodesPerElement , GradsPerElement] = ElementData(ElementType); % ElementData: Returns the number of nodes 40 | % and gradients for a given ANCF element. 41 | 42 | ModelDimensions = [1 NumElements NumNodes ElementType NCKNOT Cholesky ElementTrans]; 43 | 44 | 45 | %% Element Connectivity---------------------------------------------------- 46 | 47 | % See SamsHelp page 258 48 | 49 | Rows = NumElements; 50 | Cols = 1; 51 | 52 | ElementConnectivity = zeros(Rows, Cols); % initialize section as zeros 53 | ElementConnectivity(:,1) = ElementNumbers; % initialize first Col 54 | 55 | % Add your code here for Cols 2 and 3 56 | row1 = 1; 57 | E1 = []; 58 | F1 = []; 59 | 60 | for j = 16:-2:1 % For 8 leafs with 17 nodes for first leaf, reduced by 2 nodes for successive leaf 61 | 62 | for i=1:j 63 | E1 = [(row1) (row1+1)]; 64 | F1 = [F1;E1]; 65 | row1 = row1+1; 66 | end 67 | 68 | row1 = row1+1; 69 | end 70 | 71 | ElementConnectivity = [ElementConnectivity F1]; 72 | 73 | %% Node Locations---------------------------------------------------------- 74 | 75 | % See SamsHelp page 259 76 | 77 | NodeLocations = zeros(NumNodes, 1); 78 | NodeLocations(:,1) = NodeNumbers; 79 | 80 | % You can enter your node locations in the following format: 81 | % NodeLocations = [1 x1 y1 z1; 82 | % 2 x2 y2 z2; 83 | % 3 x3 y3 z3; 84 | % 4 x4 y4 z4; 85 | % 5 x5 y5 z5; 86 | % 6 x6 y6 z6; 87 | % 7 x7 y7 z7]; % etc.. 88 | CocNodeLocations = [data(:,1) zeros(size(data,1),1) data(:,2)]; 89 | NodeLocations = [NodeLocations, CocNodeLocations]; 90 | 91 | 92 | %% Element Properties------------------------------------------------------ 93 | 94 | % See SamsHelp page 260 95 | 96 | ElementProperties = zeros(NumElements,14); % initialize as zero in case you 97 | ElementProperties(:,1) = ElementNumbers; % want to enter some data in 98 | % the SAMS interface, the 99 | % format of this section will 100 | % be correct. 101 | 102 | 103 | %In this section you can add your element properties 104 | rhoValue = 1; % Enter the density of your material here 105 | 106 | % NOTE!!!!! 107 | % I have not include the d_x, d_y, d_z 108 | % Add your code here 109 | 110 | EValue = 100000; % Enter the Young's modulus of your material here 111 | PoissonRatioValue = 0.3; % enter the Poisson's ratio of your material here 112 | GValue = EValue/(2*(1+PoissonRatioValue)); 113 | GravityValue = 0; 114 | PhiValue = 0; 115 | EpsValue = 0; 116 | CoSyValue = 0; 117 | HValue = 0; 118 | Mu1Value = 0; 119 | Mu2Value = 0; 120 | % SplineValue = 0; 121 | 122 | % In this section the previous properties are turned into vectors 123 | rho = rhoValue*ones(NumElements, 1); 124 | 125 | % NOTE!!! 126 | % I have not include the d_x, d_y, d_z 127 | % Add your code here 128 | dx = intarclength(f,data); % Added code for 8 leafs, starting w/17 elements and reducing by 2 for each successive leaf 129 | dy = ones(NumElements,1)*0.25; % Arbitrary 130 | dz = ones(NumElements,1)*0.0100076; % Pull from leaf spring thickness 131 | 132 | E = EValue*ones(NumElements, 1); 133 | PoissonRatio = PoissonRatioValue*ones(NumElements, 1); 134 | G = GValue*ones(NumElements, 1); 135 | Gravity = GravityValue*ones(NumElements, 1); 136 | Phi = PhiValue*ones(NumElements, 1); 137 | Eps = EpsValue*ones(NumElements, 1); 138 | CoSy = CoSyValue*ones(NumElements, 1); 139 | H = HValue*ones(NumElements, 1); 140 | Mu1 = Mu1Value*ones(NumElements, 1); 141 | Mu2 = Mu2Value*ones(NumElements, 1); 142 | % Spline = Mu2Value*ones(NumElements, 1); 143 | 144 | 145 | ElementProperties = [ElementNumbers, rho, dx, dy, dz, E, G, Gravity, ... 146 | Phi, Eps, CoSy, H, Mu1, Mu2]; 147 | 148 | 149 | %% Nodal Forces------------------------------------------------------------ 150 | 151 | % See SamsHelp page 261 152 | 153 | %Assuming no nodal forces 154 | NodalForces = NoNodalForces(ElementType,NumNodes,NumNodesPerElement,NodeNumbers); 155 | 156 | %% Position Vector Gradient------------------------------------------------ 157 | 158 | % See SamsHelp page 262 159 | 160 | PositionVectorGradient = zeros(NumElements, 19); % initialize as zero in case you 161 | PositionVectorGradient(:,1) = ElementNumbers; % want to enter some data in 162 | % the SAMS interface, the 163 | % format of this section will 164 | % be correct. 165 | 166 | PositionVectorGradient = [ElementNumbers leafgrads(f,data)]; 167 | 168 | %% Begin Writing File====================================================== 169 | 170 | toc 171 | 172 | display(' ') ; 173 | display('** Writing Data **') ; 174 | display(' ') ; 175 | 176 | tic 177 | 178 | PrintANCFOutput(SAMSMode , AnalysisType , NumModels , ModelDimensions, ... 179 | ElementConnectivity, NodeLocations, ElementProperties, ... 180 | NodalForces, PositionVectorGradient, ElementType, PreSAMS_File_Name) 181 | 182 | 183 | %% End writing files------------------------------------------------------- 184 | 185 | toc 186 | display(' ') ; 187 | display('** End **') ; 188 | display(' ') ; 189 | 190 | system( PreSAMS_File_Name ); % Open file for viewing 191 | --------------------------------------------------------------------------------