Represents a non-linear spring attached between two MassObjects, generates a Force which depends on how the SpringNonLinear2 is stretched and the masses. The attraction is a gravity-like force that decreases by distance squared and is proportional to the product of the two masses. Damping is proportional to the relative velocity of the two objects.

The force equation is:

f(x) = G*m1*m2*Math.pow(x,-2)-S*Math.pow(x, -3)
x = distance between masses
G = attractive force constant
m1 = mass of body 1
m2 = mass of body 2
S = resisting force constant

The potential energy is the integral of the force:

PE(x) = -G*m1*m2*Math.pow(x,-1) + (S/2)*Math.pow(x, -2)

The minimum PE occurs where the force is zero:

G*m1*m2*Math.pow(x,-2) = S*Math.pow(x, -3)
x_min = S/(G*m1*m2)

We subtract the minimum PE from the reported PE so that PE is zero at it's minimum.

To attach one end to a fixed point you can attach to an infinite mass MassObject or a Scrim.

Hierarchy (view full)

Constructors

  • Parameters

    • name: string

      language-independent name of this object

    • body1: MassObject

      body to attach to start point of the SpringNonLinear2

    • attach1_body: GenericVector

      attachment point in body coords of body1

    • body2: MassObject

      body to attach to end point of the SpringNonLinear2

    • attach2_body: GenericVector

      attachment point in body coords of body2

    • restLength: number

      length of spring when it has no force

    • stiffness: number = 8

      strength of resisting force (default is 8)

    • attract: number = 6

      attract force constant (default is 6)

    Returns SpringNonLinear2

Properties

minPE_: number = 0

minimum potential energy

ID: number = 1

Counter used for naming SimObjects.

Methods

  • Ensures this ForceLaw is not connected to anything and so can be garbage collected. For example, if this ForceLaw is an Observer, this will stop observing its Subject.

    Returns void

  • Returns whether this SimObject has changed, and sets the state to "unchanged".

    Returns boolean

    whether this SimObject has changed

  • Returns the amount of damping for this spring. Damping is proportional to the relative velocity of the two points.

    Returns number

    amount of damping for this spring

  • Returns the expiration time, when this SimObject should be removed from the SimList. This is intended for temporary SimObjects that illustrate, for example, contact forces or collisions.

    Returns number

    the expiration time, in time frame of the Simulation clock

  • Returns the distance between start and end points of this spring

    Returns number

    the distance between start and end points of this spring

  • Name of this SimObject, either the language-independent name for scripting purposes or the localized name for display to user.

    The language-independent name should be the same as the English version but capitalized and with spaces and dashes replaced by underscore, see Util.toName, nameEquals.

    The name should give an idea of the role of the SimObject in the simulation. This allows us to to treat an object in a special way depending on its name. For example, we might use the name to decide what type of DisplayObject to create to represent the SimObject.

    Parameters

    • Optional opt_localized: boolean

      true means return the localized version of the name; default is false which means return the language independent name.

    Returns string

    name of this SimObject

  • Positive stretch means the spring is expanded, negative stretch means compressed.

    Returns number

    the amount that this line is stretched from its rest length

  • Returns length of spring that has minimum potential energy.

    Returns number

    length of spring that has minimum potential energy

  • Whether this SimObject has the given name, adjusting for transformation to the language-independent form of the name, as is done by Util.toName.

    Parameters

    • name: string

      the English or language-independent version of the name

    Returns boolean

    whether this SimObject has the given name (adjusted to language-independent form)

  • Returns potential energy for a given length of spring.

    Parameters

    • len: number

      length of spring

    Returns number

    potential energy

  • Sets attract force constant of this spring

    Parameters

    • attract: number

      the attract force constant of this spring

    Returns void

  • Sets the value of damping for this spring. Damping is proportional to the relative velocity of the two points.

    Parameters

    • damping: number

      the value of damping for this spring

    Returns Spring

    this Spring to allow chaining of setters

  • Sets the expiration time, when this SimObject should be removed from the SimList. This is intended for temporary SimObjects that illustrate, for example, contact forces or collisions.

    Parameters

    Returns void

  • Sets the rest length of this spring, which is used for calculating the stretch. When length of spring is the rest length, then no force is applied at either end.

    Parameters

    • value: number

      the rest length of this spring

    Returns void

  • Returns true if the given SimObject is similar to this SimObject for display purposes. SimObjects are similar when they are the same type and nearly the same size and location. Mainly used when showing forces - to avoid adding too many objects to the display. See SimList.getSimilar.

    Parameters

    • obj: SimObject

      the SimObject to compare to

    • Optional _opt_tolerance: number

      the amount the object components can differ by

    Returns boolean

    true if this SimObject is similar to obj for display purposes

  • Returns a minimal string representation of this object, usually giving just identity information like the class name and name of the object.

    For an object whose main purpose is to represent another Printable object, it is recommended to include the result of calling toStringShort on that other object. For example, calling toStringShort() on a DisplayShape might return something like this:

    DisplayShape{polygon:Polygon{'chain3'}}
    

    Returns string

    a minimal string representation of this object.

Generated using TypeDoc