We would like to output the results of the following program as a single-line matrix.
If niter
, use a matrix like [1,2,3,4,5,6,7....19,20]
to
rnorm
is a matrix similar to [1.2340014751660304, 0.9402715810329509..., 1.0]
.
Thank you for your cooperation.
import path as ma
d = 2500
x = 2500
area=100
e=5e5
f = 0
resid = 0
nincr = 1
fincr=1.5e7
cnorm = 1e-20
meter = 20
lzero=ma.sqrt (x**2 + d**2)
vol=area*lzero
stiff=(area/lzero)*e*(x/lzero)*(x/lzero)
for incrmin range (1,nincr+1):
f = f + fincr
resid=resid-fincr
rnorm = cnorm*2
niter = 0
while(rnorm>cnorm) and (niter<miter)):
niter=niter+1
u=resid/stiff
x = x + u
l=ma.sqrt(x*x+d*d)
area=vol/l
stress=e*ma.log(l/lzero)
t=stress*area*x/l
resid = t-f
rnorm=abs(resid/f)
stiff=(area/l)*(e-2*stress)*(x/l)*(x/l)+(stress*area/l)
print(niter)
print(rnorm)
This is what it looks like when it comes to moving code: rnorm[-1]
takes out the last element of rnorm
.I will write down only the second half of the change.
rnorm=[cnorm*2]
niter = [0]
while((rnorm[-1]>cnorm) and (niter[-1]<miter)):
niter.append(niter[-1]+1)
u=resid/stiff
x = x + u
l=ma.sqrt(x*x+d*d)
area=vol/l
stress=e*ma.log(l/lzero)
t=stress*area*x/l
resid = t-f
rnorm.append(abs(resid/f))
stiff=(area/l)*(e-2*stress)*(x/l)*(x/l)+(stress*area/l)
print(niter)
print(rnorm)
© 2025 OneMinuteCode. All rights reserved.