Model of steel wires of stranded-wire helical spring

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;
https://comet-fenics.readthedocs.io/en/latest/demo/contact/penalty.html

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

For your particular question, what is your current error message?

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

from dolfin import *


class RadioContacto(UserExpression):
    def __init__(self, carga_maxima, modulo_elasticidad, R, **kwargs):
        self.carga_maxima = carga_maxima
        self.modulo_elasticidad = modulo_elasticidad
        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
modulo_elasticidad = 200e9
R = 0.1
radio_contacto_expr = RadioContacto(
    carga_maxima, modulo_elasticidad, R, degree=1)