plaruCompute.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. # Implements plasticity algorithm
  2. import scipy as sc
  3. def radialReturn(deps, E, sigY, H = 0):
  4. """
  5. Simulate a traction experience.
  6. :param deps: A iteration vector for epsilon.
  7. :param E: Hook factor.
  8. :param sigY: Max elastic stress.
  9. :param H: Ecrouissage.
  10. :return: Three vectors (eps, sig, epsP)
  11. """
  12. # Announcement
  13. print("Computing results ...")
  14. # Prepare results
  15. n = len(deps) + 1
  16. eps = sc.zeros(n)
  17. sig = sc.zeros(n)
  18. epsP = sc.zeros(n)
  19. # Algorithm loop
  20. for k in range(0, n - 1):
  21. # Add deformation
  22. eps[k + 1] = eps[k] + deps[k]
  23. # Plastic prediction
  24. sig_pred = E*(eps[k + 1] - epsP[k])
  25. f_pred = abs(sig_pred - H*epsP[k]) - sigY
  26. # Plasticity test
  27. if f_pred < 0.0 :
  28. # Elastic domain
  29. epsP[k + 1] = epsP[k]
  30. sig[k + 1] = sig_pred
  31. else:
  32. # Radial return
  33. lda = f_pred / (E + H)
  34. epsP[k + 1] = epsP[k] + sc.sign(sig_pred - H*epsP[k])*lda
  35. sig[k + 1] = E*(eps[k + 1] - epsP[k + 1])
  36. # End of computation
  37. return (eps, sig, epsP)