Principal Stresses Program - help sought - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: HP Prime (/forum-5.html) +--- Thread: Principal Stresses Program - help sought (/thread-17755.html) |
Principal Stresses Program - help sought - trs32596 - 11-26-2021 11:42 PM Hi there, Having trouble creating a program to solve the principal stress equation. This is done by finding the roots of the third order polynomial. Here is an example of input data: σx = 60MPa σy =-30MPa σz =-20MPa τxy =40MPa Tyz = 0, Tzx = 0. Using the normal equation: σ^3 −(σx +σy +σz )⋅σ^2 +(σxσy +σxσz +σyσz −τxy^2 −τyz^2 −τzx^2 )⋅σ −(σxσyσz +2*τxy*τyz*τzx −σx*τyz^2 −σy*τzx^2 −σz*τxy^2)=0 produces roots of -45.21, -20.0, and 75.21MPa. My goal is to create a simple program to do this with the input data. Code: EXPORT PrincipalStressCoeffs(X,Y,Z,L,M,N) BEGIN LOCAL C1:= (X+Y+Z); LOCAL C2:= (X*Y+X*Z+Y*Z-L^2-M^2-N^2); LOCAL C3:= (X*Y*Z+2*L*M*N-X*M^2-Y*N^2-Z*L^2); LOCAL r = CAS( proot([1, -C1, C2, -C3]) ); RETURN(r); END; This code ends up returning imaginary numbers and not the same roots. Any help would be much appreciated. RE: Principal Stresses Program - help sought - Edwin - 11-27-2021 04:48 PM (11-26-2021 11:42 PM)trs32596 Wrote: Hi there,You can simply calculate the eigenvalues Code:
RE: Principal Stresses Program - help sought - trs32596 - 11-27-2021 07:13 PM Thanks Edwin! program works great and I completely forgot about doing eigenvalues. Thanks again! RE: Principal Stresses Program - help sought - roadrunner - 11-27-2021 07:25 PM To fix the OP's program, change this line: LOCAL r = CAS( proot([1, -C1, C2, -C3]) ); to this: LOCAL r = CAS("proot([1, -C1, C2, -C3])"); -road |