# Model of steel wires of stranded-wire helical spring

Hello every one, it’s me again, well this post has a personal propose, i’m trying to understand this powerful tool called fenics, but i am new user and i have no idea of several functions that this tool has, my goal is make a model of analysis of elliptical hertz contact of steel wires of strandes-wire helical spring, i appreciate if some one have been working in this topic and has some scripts to read and understand this element i will appreciate it very much.

Also please some one could share me how can i define user expressión to apply to my model for example a load around surface model. thanks again for helping. this is a piece of code, could some one tell me what’s wrong? :

``````class RadioContacto(UserExpression):
def __init__(self, carga_maxima, modulo_elasticidad, R, **kwargs):
self.carga_maxima = carga_maxima
self.R = R
super().__init__(**kwargs)

def eval(self, values, x):
z = x[2]
values[0] = ((3 * self.carga_maxima) / (4 * np.pi * self.modulo_elasticidad))**(1/3) * np.sqrt(self.R - z)

def value_shape(self):
return ()
carga_maxima = 1000.0
R=0.1
``````

If you ware new to FEniCS, please consider using DOLFINx: The new DOLFINx solver is now recommended over DOLFIN

Hertzian contact has been covered in several other posts on the forum, for instance;

Jeremy also has a set of demos for DOLFINx at Welcome — Computational Mechanics Numerical Tours with FEniCSx

The code you have supplied does not cause an error message for me when running it as

``````from dolfin import *

def __init__(self, carga_maxima, modulo_elasticidad, R, **kwargs):
self.carga_maxima = carga_maxima
self.R = R
super().__init__(**kwargs)

def eval(self, values, x):
z = x[2]
values[0] = ((3 * self.carga_maxima) / (4 * np.pi *

def value_shape(self):
return ()

carga_maxima = 1000.0
R = 0.1

``````

Hello DOken thank you for you answer, i apologize, the true error is in this codelines please tell me what’s wrong and thank you again for your response.

``````def modelo_hist_histeresis(deformacion, parametro_alpha, parametro_beta):
return Constant(parametro_alpha) * deformacion + Constant(parametro_beta)

parametro_alpha = 0.1
parametro_beta = 0.2
hist_histeresis = as_vector([parametro_alpha, parametro_alpha, parametro_alpha]) + \
as_vector([parametro_beta, parametro_beta, parametro_beta]) + \
as_vector([deformacion[0], deformacion[1], deformacion[2]])

# 20. Esfuerzo efectivo
esfuerzo_efectivo = hist_histeresis + as_vector([deformacion[0], deformacion[1], deformacion[2]])

# 21. Crear un objeto Expression para almacenar la expresiÃ³n de esfuerzo efectivo
class EsfuerzoEfectivo(Expression):
def __init__(self, esfuerzo_efectivo, **kwargs):
self.esfuerzo_efectivo = esfuerzo_efectivo
super().__init__(**kwargs)

def eval(self, value, x):
for i in range(3):
value[i] = self.esfuerzo_efectivo[i]

def value_shape(self):
return (3,)  # El esfuerzo efectivo es un vector 3D

# 22. Crear un objeto Expression para el esfuerzo efectivo
esfuerzo_efectivo_expr = EsfuerzoEfectivo(esfuerzo_efectivo, degree=1)
``````

error is in the class EsfuerzoEfectivo when i run this code doesn’t stop

The code supplied in the latest reply is not sufficient to reproduce your error message, as it lacks imports and definitions. Please put some effort into making a minimal reproducible example.