Method: Joules.tensile_stress

Defined in:
lib/joules/stress_strain.rb

.tensile_stress(force, area) ⇒ Float

Calculates the tensile stress given force and area.

Examples:

Joules.tensile_stress(98, 0.04) #=> 2450.0

Parameters:

  • force (Int, Float)

    force >= 0; force is in newtons

  • area (Int, Float)

    area > 0; area is in metres squared

Returns:

  • (Float)

    return value >= 0; return value is in pascals

Raises:

  • (ZeroDivisionError)

    if area = 0



26
27
28
29
30
31
32
# File 'lib/joules/stress_strain.rb', line 26

def tensile_stress(force, area)
  if area.zero?
    raise ZeroDivisionError.new('divided by 0')
  else
    return force / area.to_f
  end
end