Message Boards Message Boards

Iteration to solve det(l^2M+K)=0: error with ReplaceAll

Posted 11 years ago
Hello,

I am considering a 12 element bar. I computed the stiffness and mass matrices using the FE method.
I am assuming that the displacement of node 13 is related to the displacement of node 1 by the following relation: u13=x.u1 where x=exp(kR+i.kI)

I want to solve the following eigenvalue problem : det(Tt(lambda^2M+K)T)=0 where T is the transformation matrix for the node displacements
numele=12; numdof=numele+1;
T = Array[KroneckerDelta, {numdof, numdof - 1}];
T = ReplacePart[T, {numdof, 1} -> x];
Print["Transformation Matrix", T // MatrixForm]

Lambda is a complex frequency , i.e lambda=LR+i*wd.

I want to find kR and kI in terms of LR and wd, below is my iteration code
 For[\[Lambda]R = 0, \[Lambda]R <=
    1.1, \[Lambda]R = \[Lambda]R + 0.1, 
   For[\[Omega]d = 0, \[Omega]d <= 6, \[Omega]d = \[Omega]d + 0.5;
    sol = (Solve[Det[(-\[Lambda]R + I*\[Omega]d)^2*Mstar + Kstar] == 0,
         x][[1]]);
    x = x /. sol;
    Print[x];
    kR = Re[x];
    kI = Im[x];
   realp = AppendTo[realp, kR]; imp = AppendTo[imp, kI];
   ]];
    
(Kstar=Transpose.K.T;   Mstar=Transpose.M.T)

Since the equation det(A)=0 has 3 solutions, I am only considering the first one to start.
I want to be able to get the real part and imaginary part of x for the two iterations (one over LRand the other over wd) and plot them functions of wd and LR.

If i do Print, it gives me all the solutions, but when I try to do x=x/.sol in order to be able to getRe and Im i get an error with the Replace all command:
ReplaceAll::reps: "{False} is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing. "

I am new to Mathematica and the documentation didn't help me solve my problem.

Thanks in advance for your answers.

Clémence
POSTED BY: Clemence Bacquet
2 Replies
The ReplaceAll::reps  warning says that in
x = x /. sol;
sol is {False}.   When Solve cannot find a solution, it returns an empty list.  I do not know right off what would cause {False} .
POSTED BY: Bruce Miller
It probably causes {False} because the left hand side of the equation evaluates to a number so you get something like 2==0 or so. What is Kstar and Mstar, and how do they depend on x ?
POSTED BY: Sander Huisman
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract