# Youngs Modulus Spring Strain

I need to simulate steel strain. But I can not add enough strain. If I will, it exploding and damping values can not fix.
Here is my code:

``````Vector3 delta = distance_joint.FirstNode.transform.position - distance_joint.SecondNode.transform.position;
float deltalength = delta.magnitude;

// Calculate strain
float strain = (deltalength - distance_joint.Distance) / distance_joint.Distance;

// Calculate the spring force based on Young's Modulus
Vector3 force = delta.normalized * SpringK * strain;

// Calculate relative velocity
Vector3 relativeVelocity = distance_joint.SecondNode.GetVelocity() - distance_joint.FirstNode.GetVelocity();

// Damping coefficient (you can adjust this value)
float dampingCoefficient = SpringDamping;

// Calculate the damping force based on relative velocity
Vector3 dampingForce = -dampingCoefficient * relativeVelocity;

// Combine spring force and damping force
force += dampingForce;

// Apply forces to the connected nodes
``````

It seems like the main problem with your code is that you are calculating the spring force based on the current distance between the two nodes, rather than the initial distance. This means that the spring force will constantly increase as the nodes get further apart, which will eventually lead to an explosion.

``````Here is a modified version of your code that should work:

Vector3 delta = distance_joint.FirstNode.transform.position - distance_joint.SecondNode.transform.position;
float deltalength = delta.magnitude;

// Calculate strain
float strain = (deltalength - distance_joint.Distance) / distance_joint.InitialDistance;

// Calculate the spring force based on Young's Modulus
Vector3 force = delta.normalized * SpringK * strain;

// Calculate relative velocity
Vector3 relativeVelocity = distance_joint.SecondNode.GetVelocity() - distance_joint.FirstNode.GetVelocity();

// Damping coefficient (you can adjust this value)
float dampingCoefficient = SpringDamping;

// Calculate the damping force based on relative velocity
Vector3 dampingForce = -dampingCoefficient * relativeVelocity;

// Combine spring force and damping force
force += dampingForce;

// Apply forces to the connected nodes