Forum: Answers and discussion

Monitor Forum | Start New Thread Start New Thread
Re: function fe_mk [ Reply ]
By: Mallouli on 2016-07-29 14:33
[forum:839]

When i use your recent version, i have obtained this error : 

??? Attempt to execute SCRIPT varargin as a function:

C:\Program Files\Matlab Instal\toolbox\matlab\lang\varargin.m

 

Error in ==> fe_mk_Shudong at 33

[m,k,mdof]=fe_mk(varargin);

 

How can i correct it .


Re: function fe_mk [ Reply ]
By: Balmes on 2016-07-29 14:11
[forum:838]

Sorry but you are using a version from 1995 (21 years ago). This is beyond any possible help. We only help people who make an effort.


Re: function fe_mk [ Reply ]
By: Mallouli on 2016-07-29 13:44
[forum:837]

Hi

I must use this old verion of fe_mk : 

function [m,c,k,mdof]=fe_mk(node,elt,pl,il,mode,adof,opt)

 

%FE_MK assembly of full and reduced FE model matrices, modification matrices,

% and energies

%

%       Synopsis: [m,k,mdof]       = fe_mk(node,elt,pl,il)

%        [m,c,k,mdof]     = fe_mk(node,elt,pl,il,mode,adof,0)

%

%        [dm,dk,mdof]     = fe_mk(node,elt,pl,il,mode,adof,1)

%

%        [StEner,KinEner] = fe_mk(node,elt,pl,il,mode,adof,2)

%

% The finite element model is characterized by the matrices

%

% NODE coordinates in the Universal File format

%     ( ,1)      node number (positive integers)

%     ( ,2:4)    unused

%     ( ,5:7)    x-y-z global coordinates of the node 

%

% ELT model description matrix where each row describes the properties

%  of an element and element groups are separated by header rows of 

%  the form

%   [Inf  abs('EltFunctionName') ...]

%

%  Formats for element property rows are described in the element

%  functions. See for example

%

%  beam1  2-node 12-DOF standard beam element

%  tria3  3-node 18-DOF plate element

%  mass1   1-node  6-DOF concentrated diagonal mass/inertia

%

%       PL material property matrix

%          ( ,1)= MatId                    ( ,2)= MatType

% for isotropic materials (MatType = 1), the other elements are

%          ( ,3)= E   (Young's modulus)    ( ,4)= nu (Poisson's ratio)

%          ( ,5)= rho (density)            ( ,6)= G  (shear modulus)

%

%       IL section property matrix

%          ( ,1)= SecId                    ( ,2)= SecType

%   for the definition other values use the help of each element

%

% MODE, ADOF (optional) specify a basis of vectors onto which the

%   model should be projected. If MODE is empty, it is taken to be the 

%   identity matrix (standard model assembly with fixed DOFs). The ADOF

%   DOF definition vector may only contain wild cards for standard model

%   assembly.

%

% OPT options for the model assembly

% (1,1) type of assembly.

% 0: standard, 1: by element group,

% 2: strain and kinetic energies

%

% DOF numbering in the output model is described in the vector MDOF

% The vector MDOF first lists DOF related to nodes under the form

% NODE#.DOF#. For example y translation at node 20 as 20.02 or z

% rotation at node 10 as 10.06. (Note DOFs related to elements take

% the form -ELT#.DOF#)

%

% See also FEPLOT, FE_C, FE_EIG

 

% Etienne Balmes   10/10/90, 01/24/95

%       Copyright (c) 1990-1995 by Etienne Balmes

%       All Rights Reserved.

 

 NNode = zeros(max(node(:,1)),1);NNode(node(:,1))=[1:length(node(:,1))]';

 

 if     nargin==4              ty='mka';mode=[];adof=[];

 elseif nargin==7 & opt(1)==2  ty='ene';

 elseif nargin==7 & opt(1)==1  ty='dmk';

 elseif nargin==7 & opt(1)==0  ty='mka';

 else error('not a valid value for opt(1)');

 end

 

 EGroup = [find(elt(:,1)==Inf)' size(elt,1)+1];

 nGroup = length(EGroup)-1;nM=size(mode,2);nA=length(adof);

 

 if strcmp(ty,'mka')& nM==0

   k = spalloc(size(node,1)*6,size(node,1)*6,size(elt,1)*100);

   m = spalloc(size(node,1)*6,size(node,1)*6,size(elt,1)*100);

   if nargout==4

    c = spalloc(size(node,1)*6,size(node,1)*6,size(elt,1)*100);

   end

 elseif strcmp(ty,'mka')& nM~=0

   k = zeros(nM); m = zeros(nM);

   if nargout == 4    c = zeros(nM); end

 elseif strcmp(ty,'ene')& nM~=0

   m=zeros(size(elt,1),nM);

   if nargout==2 c=m;end

 elseif strcmp(ty,'ene')& nM==0

   error('Cannot compute energies without a mode');

 elseif strcmp(ty,'dmk') &  nM==0

   if nA==0 error('adof is empty, cannot assemble group stiffness'); end

   k = spalloc(nA*nGroup,nA,size(elt,1)*100);m=k;

   if nargout == 4    c = k; end

 elseif strcmp(ty,'dmk') & nM~=0

   k = zeros(nM*nGroup,nM); m = k;

   if nargout == 4    c = k; end

 end

 

mdof = [];EDof = [];

 

if nGroup == 0 % backward compatibility for beam only model

elt = [Inf abs('beam1') zeros(1,size(elt,2)-6);

      elt zeros(size(elt,1),size(elt,2)-6)];

nGroup = 1;EGroup = [find(elt(:,1)==Inf)' size(elt,1)+1];

end

 

% ----------------------------------------------------------------------------

% loop over element groups

for jGroup = 1:nGroup

 

ElemF = [find(elt(EGroup(jGroup),:)==0) size(elt,2)+1];

ElemF = deblank(setstr(elt(EGroup(jGroup),2:ElemF(1)-1)));

cEGI = EGroup(jGroup)+1:EGroup(jGroup+1)-1;

if exist(ElemF)==2

   eval(['eCall=' ElemF '(1);'],'eCall=[];');

else eCall=[];end

 

for jElt=1:length(cEGI)

 

  if exist(ElemF)==2

   if isempty(eCall) 

         eval(['[m1,k1,i1] = ' ElemF ...

         '(node,elt(cEGI(jElt),:),pl,il,[1 jGroup jElt]);']);

   else eval([eCall ';'])

   end

  else disp([ElemF ' : unkwown element function']);

  end

  % --------------------------------------------------------------------------

 

  if strcmp(ty,'mka')

if isempty(adof)

%aa=clock;

 ind = zeros(length(i1),1);for j2 = 1:length(i1)

           i2 = find(mdof==i1(j2));

           if isempty(i2)  mdof = [mdof;i1(j2)];ind(j2)=length(mdof);

           else            ind(j2) = i2;   end

          end

%bb=[etime(clock,aa)];aa=clock;

 k(ind,ind)=k(ind,ind)+k1;

 m(ind,ind)=m(ind,ind)+m1;

 if length(c)~=0 c(ind,ind)=c(ind,ind)+c1; end

else   % selection of DOFs

 in1=[];in2=[];for j2 = 1:length(i1)

           i2 = find(mdof==i1(j2));

           if isempty(i2)

i2 = find(adof==i1(j2));

if isempty(i2) i2=find(abs(adof-rem(i1(j2),1))<1e-7); end

if isempty(i2) i2=find(adof==fix(i1(j2))); end

                if ~isempty(i2)

   mdof = [mdof;i1(j2)];in1=[in1 length(mdof)];in2=[in2 j2];

end

           else  in1=[in1 i2];in2=[in2 j2];   end

          end  

 k(in1,in1) = k(in1,in1)+k1(in2,in2);

 m(in1,in1) = m(in1,in1)+m1(in2,in2);

 if length(c)~=0  c(in1,in1) = c(in1,in1)+c1(in2,in2);end

end

 

        if rem(cEGI(jElt),100)==0

           disp(['Done ' num2str(cEGI(jElt)) ' elements']);

        end

 

  elseif strcmp(ty,'ene')

 

ind = zeros(length(i1),1);

for j2 = 1:length(i1) ind(j2) = find(adof==i1(j2)); end

in2 = find(ind~=0); ind = ind(in2);

if ~isempty(ind);for j2 = 1:size(mode,2);

 if nargout>0

   m(cEGI(jElt),j2) = mode(ind,j2)'*k1(in2,in2)*mode(ind,j2);

 end

 if nargout>1

   c(cEGI(jElt),j2) = mode(ind,j2)'*m1(in2,in2)*mode(ind,j2);

 end

end;end

        if rem(cEGI(jElt),100)==0

         disp(['Done ' num2str(cEGI(jElt)) ' elements']);

        end

  

  elseif strcmp(ty,'dmk')

 

ind = zeros(length(i1),1);

for j2 = 1:length(i1) ind(j2) = find(adof==i1(j2)); end

in2 = find(ind~=0); ind = ind(in2);

if nM~=0 % projection of a basis of modes

 k(jGroup*nM+[-nM+1:0],:) = k(jGroup*nM+[-nM+1:0],:) + ...

      mode(ind,:)'*k1(in2,in2)*mode(ind,:);

 m(jGroup*nM+[-nM+1:0],:) = m(jGroup*nM+[-nM+1:0],:) + ...

      mode(ind,:)'*m1(in2,in2)*mode(ind,:);

 if length(c)~=0

  c(jGroup*nM+[-nM+1:0],:) = c(jGroup*nM+[-nM+1:0],:) + ...

      mode(ind,:)'*c1(in2,in2)*mode(ind,:);

          end

else  % no projection

 in3 = ind+nA*(jGroup-1);

 m(in3,ind) = m(in3,ind)+  m1(in2,in2);

 k(in3,ind) = k(in3,ind)+  k1(in2,in2);

 if length(c)~=0 c(in3,ind) = c(in3,ind)+  c1(in2,in2);end

end

        if rem(cEGI(jElt),100)==0

             disp(['Done ' num2str(cEGI(jElt)) ' elements']);

        end

  end

end

% ----------------------------------------------------------------------------

end; % end loop on element groups

 

if strcmp(ty,'ene')

  m=full(m(1:size(elt,1),1:size(mode,2)));

  if nargout>1 c=full(c(1:size(elt,1),1:size(mode,2))); end

  k=[];mdof=[];

 

elseif strcmp(ty,'mka')

  [mdof,i1]=sort(mdof); [EDof,i2]=sort(EDof); i1 = [i1;i2];

  k = k(i1,i1); m = m(i1,i1);

  if ~isempty(c) c = c(i1,i1); end

  mdof = [mdof;EDof];

 

  if nargout==2 m=k;c=mdof; end

  if nargout==3 c=k;k=mdof; end

 

elseif strcmp(ty,'dmk')

  mdof = adof;

  if nargout==2 m=k;c=mdof; end

  if nargout==3 c=k;k=mdof; end

end

 
 
 
 
 
I can't obtain any result with this version ? 
Please help me 

Re: function fe_mk [ Reply ]
By: Balmes on 2016-07-29 13:22
[forum:836]

You must note that I said fe_mknl not fe_mk. It is necessary that you use the functions in their current SVN status that is available on this web site

http://support.sdtools.com/gf/project/openfem/scmsvn/?action=browse&path=%2Ftrunk%2F

 


Re: function fe_mk [ Reply ]
By: Mallouli on 2016-07-29 13:10
[forum:835]

 Hi

I have obtained this error 

 

??? Undefined function or method 'max' for input arguments of type 'struct'.

Error in ==> fe_mk at 3

 NNode = zeros( max(node(:,1)),1);NNode(node(:,1))=(1:length(node(:,1)))';

Error in ==> fe_mk_Shudong at 32

model=fe_mk(model); % Assemble mass and stiffness in model.K{1:2)

 

 

 

Is it necessary to send you the fe_mk function ?


Re: function fe_mk [ Reply ]
By: Balmes on 2016-07-28 13:47
[forum:834]

Well for nearly 10 years the call has been

model=struct('Node',node,'Elt',elt,'pl',pl,'il',il);
model=fe_mknl(model); % Assemble mass and stiffness in model.K{1:2}


Re: function fe_mk [ Reply ]
By: Mallouli on 2016-07-28 12:08
[forum:833]

 Hi

My principle program intitled fe_mk_shodong is below and my problem is in the formula of function fe_mk

%for the correct display of pl

format long g;

format compact;

%   node#  unused      x            y          z

node=[1    0 0 0       0            0          0;

      2    0 0 0       25.4e-03     0          0;

      3    0 0 0       50.8e-03     0          0;

      4    0 0 0       1            1          1];

elt=[  

%declaration of elemnt groupe

    Inf abs('beam1')

 %node1   node2    pl     il     refnode

   1       2       1      1          4       0    %longerons

   2       3       1      1          4       0];

 

%     matid       matType        E            nu          rho

pl=[   1            1           10.5e+10     3.4e-01     9e+03];

 

%     secId      SecType        J            i1             i2            A

il=[    1          1          3.75e-10     7.27e-15      3.75e-10     4.452e-06 ];   %longerons

 

opt=[0 1 2];

%mode=[];

 

%Boundary conditions (Active DOF's)---------------------------------------- 

%adof=[2.02 2.06   3.02 3.06];

 

%call of function 

 [m,k,mdof]=fe_mk(node,elt,pl,il,[ ],[ ],opt);


Re: function fe_mk [ Reply ]
By: Balmes on 2016-07-27 16:40
[forum:832]

To expect any help, you need to provide a working example. You did not provide node,elt,pl,[],[],opt)  and note that this is a very obsolete call.

 


function fe_mk [ Reply ]
By: Mallouli on 2016-07-27 15:14
[forum:831]

 Hi

I have this function [m,c,k,mdof] = fe_mk (node,elt,pl,il,mode,adof,opt)

but when i call it in the principle program with little output argument like this: 

[m,k,mdof]=fe_mk(node,elt,pl,il,[ ],[ ],opt);

An error message will be diplayed like this 

 Undefined function or variable "c"

Error in ==> fe_mk at 80

 if length(c)~=0  c(ind,ind)=c(ind,ind)+c1; end

Error in ==> fe_mk_Shudong at 30

 [m,k,mdof]=fe_mk(node,elt,pl,il,[],[],opt);

 

Please help me.