Borrar filtros
Borrar filtros

Output matrix format for use in another program

1 visualización (últimos 30 días)
Carly
Carly el 7 de Oct. de 2016
Respondida: KSSV el 8 de Oct. de 2016
I need to write a program that will give me output matrices k, T, and K for use in another program. These matrices refer to stiffness properties of beams and the program is used to get k, T, and K for all the beams in a 2D structure, so there are multiple k, T, and K matrices. I have written the program, called 'GenerateMemberStiffness', to output k, T, and K. The program 'PlaneTruss' takes the matrices from 'GenerateMemberStiffness' and puts them into 3D matrices with the third dimension being the number of beams that are being analyzed. 'PlaneTruss' was already written (and is definitely correct) and has to be used the way it is. The part of the code of 'PlaneTruss' that does this is the following:
% Initiate empty three-dimensional matrices for storing local stiffness,
% transformation, and global stiffness matrices. The index in the 3rd
% variable dimension refers to the member number. For example,
% localMemberStiff_k(:,:,2) is the local stiffness matrix of the member-2.
localMemberStiff_k = zeros(2 * NCJT, 2 * NCJT, numMembers);
transMatrix_T = zeros(2 * NCJT, 2 * NCJT, numMembers);
globalMemberStiff_K = zeros(2 * NCJT, 2 * NCJT, numMembers);
%
% Generate the member stiffness matrices in local and global coordinates,
% and generate the transformation matrix for each member.
for i = 1 : numMembers
memberCodeNumbers(i,:) = [jointDOFsAndRestraints(members(i,1), :) ...
jointDOFsAndRestraints(members(i,2), :)] ;
%
[localMemberStiff_k(:,:,i), transMatrix_T(:,:,i), globalMemberStiff_K(:,:,i)] = ...
GenerateMemberStiffness(jointCoords, members(i, 1:2), ...
youngsModuli_E(members(i,3)), sectionAreas_A(members(i,4)) ) ;
end
Although I was able to write the code for 'GenerateMemberStiffness' to output multiple k,T,and K matrices I do not think they are being outputted in the correct format, because when I try to run 'PlaneTruss' I do not get the correct answers. My code for 'GenerateMemberStiffness' is the following:
function [k, T, K] = ...
GenerateMemberStiffness(jointCoords, memberJoints, E, A)
%
% Input:
% jointCoords: Joint coordinates in the global coordinate system
% given in "InputParameters.m"
% memberJoints: a 1-by-2 row vector containing the beginning & end
% joint numbers of the member
% E: a scalar - Young's modulus of this member
% A: a scalar - Cross section area of this member
%
% Output: Three matrices for storing local stiffness,
% transformation, and global stiffness matrices.
%
% k: the stiffness matrix of a member in local coordinates
% T: the transformation matrix between global and local coordinates
% K: the stiffness matrix of a member in global coordinates
InputParameters;
memberJoints=members(:,1:2);
memberEA=members(:,3:4);
EA=zeros(1,length(memberJoints));
EAL=zeros(1,length(memberJoints));
kbase=[1,0,-1,0;0,0,0,0;-1,0,1,0;0,0,0,0];
for i=1:length(memberJoints)
n1=memberJoints(i,1);
n2=memberJoints(i,2);
n3=memberEA(i,1);
n4=memberEA(i,2);
n5=jointCoords(n1,1);
n6=jointCoords(n1,2);
n7=jointCoords(n2,1);
n8=jointCoords(n2,2);
distance(i)=pdist([n5,n6; n7,n8],'euclidean')
EA(i)=youngsModuli_E(n3,1)*sectionAreas_A(n4,1)
EAL(i)=EA(i)/distance(i)
k=EAL(i)*kbase
n9=(n7-n5)/distance(i)
n10=(n8-n6)/distance(i)
T=[n9,n10,0,0;-n10,n9,0,0;0,0,n9,n10;0,0,-n10,n9]
K=T'*k*T
end
I don't really understand the formatting required for use in 'PlaneTruss'. What is incorrect about how I have written 'GenerateMemberStiffness'? Please note, in 'GenerateMemberStiffness' members, jointCoords, youngsModuli, and sectionAreas are referring to other matrices of variable sizes that are loaded in from InputParameters. These matrices change size based on the number of elements of the structure currently being analyzed. The matrices I am using to test the code are:
jointCoords=[0 0
240 0
480 0
0 192
240 192];
supportData=[1 1 1
4 1 1];
youngsModuli_E=[29000];
sectionAreas_A=[8
6];
members=[ 1 2 1 1
2 3 1 1
4 5 1 1
1 5 1 2
2 4 1 2
2 5 1 2
3 5 1 1];

Respuestas (1)

KSSV
KSSV el 8 de Oct. de 2016
It is a FEM problem. GenerateMemberStiffness generates required stiffness matrices. The function needs coordinates and respective nodal connectivity, Young's modulus and cross section of the beam. It is a 1d problem. I guess you are giving Nidal connectivity matrix wrong. Nodal connectivity should be nx2 matrix.

Categorías

Más información sobre Logical en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by