kill(all)$

maxima: finite element (=discrete), version 1.0,part 1
peter.vlasschaert@gmail.com,03/01/2021

physical system :ki (= physical constant)

rem : ki = k[i] ,physical constant.
rem : 1e :first element       : node(1)→node(2)
         2e :second element : node(2)→node(3)
         3e :third element      : node(3)→node(4)

→ local  element : node(i) →node(j), ll = 1e,2e,3e, 'see above'

numel(ll):=[ll,ll+1];

m:makelist(numel(i),i,1,3);

=> first element : ll =1 ( = 1e)

node(i) →node(j) => node(1) →node(2)

m[1];

node(i) = node(1)

m[1][1];

node(j) = node(2)

m[1][2];

→ dimension : generation K (= stiffness matrix )

K:genmatrix(v, length(m)+1, length(m)+1);

Dimensions of a Matrix: K
==================

 ======================================================

matsize(AA):=[length(AA),length(transpose(AA))];

p1:matsize(K);

→ number of rows:

p1a:p1[1];

→ number of columns:

p1b:p1[2];

 =====================================================

→ def : elemental matrix :h ( = physical matrix)

elmat(h):=matrix([k[h],-k[h]],[-k[h],k[h]]);

physical matrix  : h =1

elmat(1);

v[1,1]:elmat(1)[1,1];

g1:ev(K,nouns);

→ construct : zero matrix ( v[i,j] = 0, i=1,2,..,numnber of rows,
                                                    j=1,2,...,number of columns)

maxima : combination : double list ( otherwise use : double "for loop")

ss:makelist(makelist(v[i2,j2]:0,i2,1,p1a),j2,1,p1b);

→ fill  K =stiffness matrix with : physical matrix( =elmat(ei))

ellmatt(ei,mm):=block([ik,jk,ii,jj],
s1:elmat(ei),
s2:makelist(numel(jj),jj,1,mm),    
s3:makelist(jj,jj,0,mm-1),/*correction 2by2 matrix*/         
for ik:s2[ei][1] thru s2[ei][2] do(
    for jk:s2[ei][1] thru s2[ei][2] do(            
        v[ik,jk]:elmat(ei)[ik-s3[ei],jk-s3[ei]]        
    )  
  )   
)$  

ei     = element
mm  =  total number of elements

grind(ellmatt)$/*optimized code:ellmat */

→ combination  : elemental matrix (=elmat(h))

1e) step : combine.
---------------------------------------------------------------

sum(ellmatt(ii,p1a-1),ii,1,p1a-1)$

K1:ev(K,nouns);

2e) step : correction for combine  (interaction)
-------------------------------------------------------------
v[2,2] = v[2,2] + x
v[3,3] = v[3,3] + y
-------------------------------------------------------------
x,y : interaction between element 
x : 1e & 2e
y : 2e & 3e
------------------------------------------------------------

v[2,2]:v[2,2]+x;
v[3,3]:v[3,3]+y;

K:ev(K,nouns);

x:k[1];/* physical matrix:ll =1*/
y:k[2];/* physical matrix:ll =2*/

K:ev(K,nouns);