-1

I need to solve this system of matrices for the unkowns u4,f1,f2,f3,f5 and f6 for a particular FEA problem. I have generated the matrix containing the numbers with my input and need to solve it for these knowns.

  • The code should act as follows:

    0 + 0 + 0 + 150*1000*u4 + 0 + 0 = −1732

therefore, u4=-0.01154

  • so the other unknowns can be found out as follows:

    0 + 0 + 0 + (43:4)(−0:0115) 1000 + 0 + 0 = f1

therefore f1=-500 and so on....

I am a beginner and familiar with the basics of numpy and python OOP. Please help me set up a code for this.

The matrices to be solved

bahrep
  • 29,961
  • 12
  • 103
  • 150
nilesh
  • 188
  • 1
  • 2
  • 14

2 Answers2

1
In [0]: import numpy as np    

In [1]: A = np.random.rand(6,6)

In [2]: a4 = A[3,:]

In [3]: u4 = -1732/a4[3]

In [4]: f = a4*u4

In [5]: f
Out[5]: 
array([ -246.6101995 ,  -589.6732277 ,  -574.67690895, -1732.        ,
       -2592.99948033, -2383.52077134])

Replace A or atleast the fourth column a4 by your data...

Jan
  • 4,932
  • 1
  • 26
  • 30
  • Thanks for your response, but I need the code to determine the sequence and operators automatically. The code will be reused and the unknowns might be u2 and f5 or any other combination for different cases. The user has to only enter the 3 matrices and the unknowns should be calculated by the code. – nilesh Apr 06 '13 at 09:39
1

Here it is:

from __future__ import division
from numpy import asarray as ar,sum as sums

A = ar([[25,-43.3,-25,43.3,0,0],
        [-43.3,75,43.3,-75,0,0],
        [-25,43.3,50,0,-25,-43.3],
        [43.3,-75,0,150,-43.3,-75],
        [0,0,-25,-43.3,25,43.3],
        [0,0,-43.3,-75,43.3,75]])*1e3
u4 = -0.01154
B = ar([0,0,0,u4,0,0])
F = sums(A*B,axis=1)

So you will have:

>>> F
array([ -499.682,   865.5  ,     0.   , -1731.   ,   499.682,   865.5  ])
Developer
  • 8,258
  • 8
  • 49
  • 58