Spaces:
Running
Running
File size: 26,558 Bytes
6a86ad5 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 |
"""Implementations of pathways for use by actuators."""
from abc import ABC, abstractmethod
from sympy.core.singleton import S
from sympy.physics.mechanics.loads import Force
from sympy.physics.mechanics.wrapping_geometry import WrappingGeometryBase
from sympy.physics.vector import Point, dynamicsymbols
__all__ = ['PathwayBase', 'LinearPathway', 'ObstacleSetPathway',
'WrappingPathway']
class PathwayBase(ABC):
"""Abstract base class for all pathway classes to inherit from.
Notes
=====
Instances of this class cannot be directly instantiated by users. However,
it can be used to created custom pathway types through subclassing.
"""
def __init__(self, *attachments):
"""Initializer for ``PathwayBase``."""
self.attachments = attachments
@property
def attachments(self):
"""The pair of points defining a pathway's ends."""
return self._attachments
@attachments.setter
def attachments(self, attachments):
if hasattr(self, '_attachments'):
msg = (
f'Can\'t set attribute `attachments` to {repr(attachments)} '
f'as it is immutable.'
)
raise AttributeError(msg)
if len(attachments) != 2:
msg = (
f'Value {repr(attachments)} passed to `attachments` was an '
f'iterable of length {len(attachments)}, must be an iterable '
f'of length 2.'
)
raise ValueError(msg)
for i, point in enumerate(attachments):
if not isinstance(point, Point):
msg = (
f'Value {repr(point)} passed to `attachments` at index '
f'{i} was of type {type(point)}, must be {Point}.'
)
raise TypeError(msg)
self._attachments = tuple(attachments)
@property
@abstractmethod
def length(self):
"""An expression representing the pathway's length."""
pass
@property
@abstractmethod
def extension_velocity(self):
"""An expression representing the pathway's extension velocity."""
pass
@abstractmethod
def to_loads(self, force):
"""Loads required by the equations of motion method classes.
Explanation
===========
``KanesMethod`` requires a list of ``Point``-``Vector`` tuples to be
passed to the ``loads`` parameters of its ``kanes_equations`` method
when constructing the equations of motion. This method acts as a
utility to produce the correctly-structred pairs of points and vectors
required so that these can be easily concatenated with other items in
the list of loads and passed to ``KanesMethod.kanes_equations``. These
loads are also in the correct form to also be passed to the other
equations of motion method classes, e.g. ``LagrangesMethod``.
"""
pass
def __repr__(self):
"""Default representation of a pathway."""
attachments = ', '.join(str(a) for a in self.attachments)
return f'{self.__class__.__name__}({attachments})'
class LinearPathway(PathwayBase):
"""Linear pathway between a pair of attachment points.
Explanation
===========
A linear pathway forms a straight-line segment between two points and is
the simplest pathway that can be formed. It will not interact with any
other objects in the system, i.e. a ``LinearPathway`` will intersect other
objects to ensure that the path between its two ends (its attachments) is
the shortest possible.
A linear pathway is made up of two points that can move relative to each
other, and a pair of equal and opposite forces acting on the points. If the
positive time-varying Euclidean distance between the two points is defined,
then the "extension velocity" is the time derivative of this distance. The
extension velocity is positive when the two points are moving away from
each other and negative when moving closer to each other. The direction for
the force acting on either point is determined by constructing a unit
vector directed from the other point to this point. This establishes a sign
convention such that a positive force magnitude tends to push the points
apart. The following diagram shows the positive force sense and the
distance between the points::
P Q
o<--- F --->o
| |
|<--l(t)--->|
Examples
========
>>> from sympy.physics.mechanics import LinearPathway
To construct a pathway, two points are required to be passed to the
``attachments`` parameter as a ``tuple``.
>>> from sympy.physics.mechanics import Point
>>> pA, pB = Point('pA'), Point('pB')
>>> linear_pathway = LinearPathway(pA, pB)
>>> linear_pathway
LinearPathway(pA, pB)
The pathway created above isn't very interesting without the positions and
velocities of its attachment points being described. Without this its not
possible to describe how the pathway moves, i.e. its length or its
extension velocity.
>>> from sympy.physics.mechanics import ReferenceFrame
>>> from sympy.physics.vector import dynamicsymbols
>>> N = ReferenceFrame('N')
>>> q = dynamicsymbols('q')
>>> pB.set_pos(pA, q*N.x)
>>> pB.pos_from(pA)
q(t)*N.x
A pathway's length can be accessed via its ``length`` attribute.
>>> linear_pathway.length
sqrt(q(t)**2)
Note how what appears to be an overly-complex expression is returned. This
is actually required as it ensures that a pathway's length is always
positive.
A pathway's extension velocity can be accessed similarly via its
``extension_velocity`` attribute.
>>> linear_pathway.extension_velocity
sqrt(q(t)**2)*Derivative(q(t), t)/q(t)
Parameters
==========
attachments : tuple[Point, Point]
Pair of ``Point`` objects between which the linear pathway spans.
Constructor expects two points to be passed, e.g.
``LinearPathway(Point('pA'), Point('pB'))``. More or fewer points will
cause an error to be thrown.
"""
def __init__(self, *attachments):
"""Initializer for ``LinearPathway``.
Parameters
==========
attachments : Point
Pair of ``Point`` objects between which the linear pathway spans.
Constructor expects two points to be passed, e.g.
``LinearPathway(Point('pA'), Point('pB'))``. More or fewer points
will cause an error to be thrown.
"""
super().__init__(*attachments)
@property
def length(self):
"""Exact analytical expression for the pathway's length."""
return _point_pair_length(*self.attachments)
@property
def extension_velocity(self):
"""Exact analytical expression for the pathway's extension velocity."""
return _point_pair_extension_velocity(*self.attachments)
def to_loads(self, force):
"""Loads required by the equations of motion method classes.
Explanation
===========
``KanesMethod`` requires a list of ``Point``-``Vector`` tuples to be
passed to the ``loads`` parameters of its ``kanes_equations`` method
when constructing the equations of motion. This method acts as a
utility to produce the correctly-structred pairs of points and vectors
required so that these can be easily concatenated with other items in
the list of loads and passed to ``KanesMethod.kanes_equations``. These
loads are also in the correct form to also be passed to the other
equations of motion method classes, e.g. ``LagrangesMethod``.
Examples
========
The below example shows how to generate the loads produced in a linear
actuator that produces an expansile force ``F``. First, create a linear
actuator between two points separated by the coordinate ``q`` in the
``x`` direction of the global frame ``N``.
>>> from sympy.physics.mechanics import (LinearPathway, Point,
... ReferenceFrame)
>>> from sympy.physics.vector import dynamicsymbols
>>> q = dynamicsymbols('q')
>>> N = ReferenceFrame('N')
>>> pA, pB = Point('pA'), Point('pB')
>>> pB.set_pos(pA, q*N.x)
>>> linear_pathway = LinearPathway(pA, pB)
Now create a symbol ``F`` to describe the magnitude of the (expansile)
force that will be produced along the pathway. The list of loads that
``KanesMethod`` requires can be produced by calling the pathway's
``to_loads`` method with ``F`` passed as the only argument.
>>> from sympy import symbols
>>> F = symbols('F')
>>> linear_pathway.to_loads(F)
[(pA, - F*q(t)/sqrt(q(t)**2)*N.x), (pB, F*q(t)/sqrt(q(t)**2)*N.x)]
Parameters
==========
force : Expr
Magnitude of the force acting along the length of the pathway. As
per the sign conventions for the pathway length, pathway extension
velocity, and pair of point forces, if this ``Expr`` is positive
then the force will act to push the pair of points away from one
another (it is expansile).
"""
relative_position = _point_pair_relative_position(*self.attachments)
loads = [
Force(self.attachments[0], -force*relative_position/self.length),
Force(self.attachments[-1], force*relative_position/self.length),
]
return loads
class ObstacleSetPathway(PathwayBase):
"""Obstacle-set pathway between a set of attachment points.
Explanation
===========
An obstacle-set pathway forms a series of straight-line segment between
pairs of consecutive points in a set of points. It is similiar to multiple
linear pathways joined end-to-end. It will not interact with any other
objects in the system, i.e. an ``ObstacleSetPathway`` will intersect other
objects to ensure that the path between its pairs of points (its
attachments) is the shortest possible.
Examples
========
To construct an obstacle-set pathway, three or more points are required to
be passed to the ``attachments`` parameter as a ``tuple``.
>>> from sympy.physics.mechanics import ObstacleSetPathway, Point
>>> pA, pB, pC, pD = Point('pA'), Point('pB'), Point('pC'), Point('pD')
>>> obstacle_set_pathway = ObstacleSetPathway(pA, pB, pC, pD)
>>> obstacle_set_pathway
ObstacleSetPathway(pA, pB, pC, pD)
The pathway created above isn't very interesting without the positions and
velocities of its attachment points being described. Without this its not
possible to describe how the pathway moves, i.e. its length or its
extension velocity.
>>> from sympy import cos, sin
>>> from sympy.physics.mechanics import ReferenceFrame
>>> from sympy.physics.vector import dynamicsymbols
>>> N = ReferenceFrame('N')
>>> q = dynamicsymbols('q')
>>> pO = Point('pO')
>>> pA.set_pos(pO, N.y)
>>> pB.set_pos(pO, -N.x)
>>> pC.set_pos(pA, cos(q) * N.x - (sin(q) + 1) * N.y)
>>> pD.set_pos(pA, sin(q) * N.x + (cos(q) - 1) * N.y)
>>> pB.pos_from(pA)
- N.x - N.y
>>> pC.pos_from(pA)
cos(q(t))*N.x + (-sin(q(t)) - 1)*N.y
>>> pD.pos_from(pA)
sin(q(t))*N.x + (cos(q(t)) - 1)*N.y
A pathway's length can be accessed via its ``length`` attribute.
>>> obstacle_set_pathway.length.simplify()
sqrt(2)*(sqrt(cos(q(t)) + 1) + 2)
A pathway's extension velocity can be accessed similarly via its
``extension_velocity`` attribute.
>>> obstacle_set_pathway.extension_velocity.simplify()
-sqrt(2)*sin(q(t))*Derivative(q(t), t)/(2*sqrt(cos(q(t)) + 1))
Parameters
==========
attachments : tuple[Point, Point]
The set of ``Point`` objects that define the segmented obstacle-set
pathway.
"""
def __init__(self, *attachments):
"""Initializer for ``ObstacleSetPathway``.
Parameters
==========
attachments : tuple[Point, ...]
The set of ``Point`` objects that define the segmented obstacle-set
pathway.
"""
super().__init__(*attachments)
@property
def attachments(self):
"""The set of points defining a pathway's segmented path."""
return self._attachments
@attachments.setter
def attachments(self, attachments):
if hasattr(self, '_attachments'):
msg = (
f'Can\'t set attribute `attachments` to {repr(attachments)} '
f'as it is immutable.'
)
raise AttributeError(msg)
if len(attachments) <= 2:
msg = (
f'Value {repr(attachments)} passed to `attachments` was an '
f'iterable of length {len(attachments)}, must be an iterable '
f'of length 3 or greater.'
)
raise ValueError(msg)
for i, point in enumerate(attachments):
if not isinstance(point, Point):
msg = (
f'Value {repr(point)} passed to `attachments` at index '
f'{i} was of type {type(point)}, must be {Point}.'
)
raise TypeError(msg)
self._attachments = tuple(attachments)
@property
def length(self):
"""Exact analytical expression for the pathway's length."""
length = S.Zero
attachment_pairs = zip(self.attachments[:-1], self.attachments[1:])
for attachment_pair in attachment_pairs:
length += _point_pair_length(*attachment_pair)
return length
@property
def extension_velocity(self):
"""Exact analytical expression for the pathway's extension velocity."""
extension_velocity = S.Zero
attachment_pairs = zip(self.attachments[:-1], self.attachments[1:])
for attachment_pair in attachment_pairs:
extension_velocity += _point_pair_extension_velocity(*attachment_pair)
return extension_velocity
def to_loads(self, force):
"""Loads required by the equations of motion method classes.
Explanation
===========
``KanesMethod`` requires a list of ``Point``-``Vector`` tuples to be
passed to the ``loads`` parameters of its ``kanes_equations`` method
when constructing the equations of motion. This method acts as a
utility to produce the correctly-structred pairs of points and vectors
required so that these can be easily concatenated with other items in
the list of loads and passed to ``KanesMethod.kanes_equations``. These
loads are also in the correct form to also be passed to the other
equations of motion method classes, e.g. ``LagrangesMethod``.
Examples
========
The below example shows how to generate the loads produced in an
actuator that follows an obstacle-set pathway between four points and
produces an expansile force ``F``. First, create a pair of reference
frames, ``A`` and ``B``, in which the four points ``pA``, ``pB``,
``pC``, and ``pD`` will be located. The first two points in frame ``A``
and the second two in frame ``B``. Frame ``B`` will also be oriented
such that it relates to ``A`` via a rotation of ``q`` about an axis
``N.z`` in a global frame (``N.z``, ``A.z``, and ``B.z`` are parallel).
>>> from sympy.physics.mechanics import (ObstacleSetPathway, Point,
... ReferenceFrame)
>>> from sympy.physics.vector import dynamicsymbols
>>> q = dynamicsymbols('q')
>>> N = ReferenceFrame('N')
>>> N = ReferenceFrame('N')
>>> A = N.orientnew('A', 'axis', (0, N.x))
>>> B = A.orientnew('B', 'axis', (q, N.z))
>>> pO = Point('pO')
>>> pA, pB, pC, pD = Point('pA'), Point('pB'), Point('pC'), Point('pD')
>>> pA.set_pos(pO, A.x)
>>> pB.set_pos(pO, -A.y)
>>> pC.set_pos(pO, B.y)
>>> pD.set_pos(pO, B.x)
>>> obstacle_set_pathway = ObstacleSetPathway(pA, pB, pC, pD)
Now create a symbol ``F`` to describe the magnitude of the (expansile)
force that will be produced along the pathway. The list of loads that
``KanesMethod`` requires can be produced by calling the pathway's
``to_loads`` method with ``F`` passed as the only argument.
>>> from sympy import Symbol
>>> F = Symbol('F')
>>> obstacle_set_pathway.to_loads(F)
[(pA, sqrt(2)*F/2*A.x + sqrt(2)*F/2*A.y),
(pB, - sqrt(2)*F/2*A.x - sqrt(2)*F/2*A.y),
(pB, - F/sqrt(2*cos(q(t)) + 2)*A.y - F/sqrt(2*cos(q(t)) + 2)*B.y),
(pC, F/sqrt(2*cos(q(t)) + 2)*A.y + F/sqrt(2*cos(q(t)) + 2)*B.y),
(pC, - sqrt(2)*F/2*B.x + sqrt(2)*F/2*B.y),
(pD, sqrt(2)*F/2*B.x - sqrt(2)*F/2*B.y)]
Parameters
==========
force : Expr
The force acting along the length of the pathway. It is assumed
that this ``Expr`` represents an expansile force.
"""
loads = []
attachment_pairs = zip(self.attachments[:-1], self.attachments[1:])
for attachment_pair in attachment_pairs:
relative_position = _point_pair_relative_position(*attachment_pair)
length = _point_pair_length(*attachment_pair)
loads.extend([
Force(attachment_pair[0], -force*relative_position/length),
Force(attachment_pair[1], force*relative_position/length),
])
return loads
class WrappingPathway(PathwayBase):
"""Pathway that wraps a geometry object.
Explanation
===========
A wrapping pathway interacts with a geometry object and forms a path that
wraps smoothly along its surface. The wrapping pathway along the geometry
object will be the geodesic that the geometry object defines based on the
two points. It will not interact with any other objects in the system, i.e.
a ``WrappingPathway`` will intersect other objects to ensure that the path
between its two ends (its attachments) is the shortest possible.
To explain the sign conventions used for pathway length, extension
velocity, and direction of applied forces, we can ignore the geometry with
which the wrapping pathway interacts. A wrapping pathway is made up of two
points that can move relative to each other, and a pair of equal and
opposite forces acting on the points. If the positive time-varying
Euclidean distance between the two points is defined, then the "extension
velocity" is the time derivative of this distance. The extension velocity
is positive when the two points are moving away from each other and
negative when moving closer to each other. The direction for the force
acting on either point is determined by constructing a unit vector directed
from the other point to this point. This establishes a sign convention such
that a positive force magnitude tends to push the points apart. The
following diagram shows the positive force sense and the distance between
the points::
P Q
o<--- F --->o
| |
|<--l(t)--->|
Examples
========
>>> from sympy.physics.mechanics import WrappingPathway
To construct a wrapping pathway, like other pathways, a pair of points must
be passed, followed by an instance of a wrapping geometry class as a
keyword argument. We'll use a cylinder with radius ``r`` and its axis
parallel to ``N.x`` passing through a point ``pO``.
>>> from sympy import symbols
>>> from sympy.physics.mechanics import Point, ReferenceFrame, WrappingCylinder
>>> r = symbols('r')
>>> N = ReferenceFrame('N')
>>> pA, pB, pO = Point('pA'), Point('pB'), Point('pO')
>>> cylinder = WrappingCylinder(r, pO, N.x)
>>> wrapping_pathway = WrappingPathway(pA, pB, cylinder)
>>> wrapping_pathway
WrappingPathway(pA, pB, geometry=WrappingCylinder(radius=r, point=pO,
axis=N.x))
Parameters
==========
attachment_1 : Point
First of the pair of ``Point`` objects between which the wrapping
pathway spans.
attachment_2 : Point
Second of the pair of ``Point`` objects between which the wrapping
pathway spans.
geometry : WrappingGeometryBase
Geometry about which the pathway wraps.
"""
def __init__(self, attachment_1, attachment_2, geometry):
"""Initializer for ``WrappingPathway``.
Parameters
==========
attachment_1 : Point
First of the pair of ``Point`` objects between which the wrapping
pathway spans.
attachment_2 : Point
Second of the pair of ``Point`` objects between which the wrapping
pathway spans.
geometry : WrappingGeometryBase
Geometry about which the pathway wraps.
The geometry about which the pathway wraps.
"""
super().__init__(attachment_1, attachment_2)
self.geometry = geometry
@property
def geometry(self):
"""Geometry around which the pathway wraps."""
return self._geometry
@geometry.setter
def geometry(self, geometry):
if hasattr(self, '_geometry'):
msg = (
f'Can\'t set attribute `geometry` to {repr(geometry)} as it '
f'is immutable.'
)
raise AttributeError(msg)
if not isinstance(geometry, WrappingGeometryBase):
msg = (
f'Value {repr(geometry)} passed to `geometry` was of type '
f'{type(geometry)}, must be {WrappingGeometryBase}.'
)
raise TypeError(msg)
self._geometry = geometry
@property
def length(self):
"""Exact analytical expression for the pathway's length."""
return self.geometry.geodesic_length(*self.attachments)
@property
def extension_velocity(self):
"""Exact analytical expression for the pathway's extension velocity."""
return self.length.diff(dynamicsymbols._t)
def to_loads(self, force):
"""Loads required by the equations of motion method classes.
Explanation
===========
``KanesMethod`` requires a list of ``Point``-``Vector`` tuples to be
passed to the ``loads`` parameters of its ``kanes_equations`` method
when constructing the equations of motion. This method acts as a
utility to produce the correctly-structred pairs of points and vectors
required so that these can be easily concatenated with other items in
the list of loads and passed to ``KanesMethod.kanes_equations``. These
loads are also in the correct form to also be passed to the other
equations of motion method classes, e.g. ``LagrangesMethod``.
Examples
========
The below example shows how to generate the loads produced in an
actuator that produces an expansile force ``F`` while wrapping around a
cylinder. First, create a cylinder with radius ``r`` and an axis
parallel to the ``N.z`` direction of the global frame ``N`` that also
passes through a point ``pO``.
>>> from sympy import symbols
>>> from sympy.physics.mechanics import (Point, ReferenceFrame,
... WrappingCylinder)
>>> N = ReferenceFrame('N')
>>> r = symbols('r', positive=True)
>>> pO = Point('pO')
>>> cylinder = WrappingCylinder(r, pO, N.z)
Create the pathway of the actuator using the ``WrappingPathway`` class,
defined to span between two points ``pA`` and ``pB``. Both points lie
on the surface of the cylinder and the location of ``pB`` is defined
relative to ``pA`` by the dynamics symbol ``q``.
>>> from sympy import cos, sin
>>> from sympy.physics.mechanics import WrappingPathway, dynamicsymbols
>>> q = dynamicsymbols('q')
>>> pA = Point('pA')
>>> pB = Point('pB')
>>> pA.set_pos(pO, r*N.x)
>>> pB.set_pos(pO, r*(cos(q)*N.x + sin(q)*N.y))
>>> pB.pos_from(pA)
(r*cos(q(t)) - r)*N.x + r*sin(q(t))*N.y
>>> pathway = WrappingPathway(pA, pB, cylinder)
Now create a symbol ``F`` to describe the magnitude of the (expansile)
force that will be produced along the pathway. The list of loads that
``KanesMethod`` requires can be produced by calling the pathway's
``to_loads`` method with ``F`` passed as the only argument.
>>> F = symbols('F')
>>> loads = pathway.to_loads(F)
>>> [load.__class__(load.location, load.vector.simplify()) for load in loads]
[(pA, F*N.y), (pB, F*sin(q(t))*N.x - F*cos(q(t))*N.y),
(pO, - F*sin(q(t))*N.x + F*(cos(q(t)) - 1)*N.y)]
Parameters
==========
force : Expr
Magnitude of the force acting along the length of the pathway. It
is assumed that this ``Expr`` represents an expansile force.
"""
pA, pB = self.attachments
pO = self.geometry.point
pA_force, pB_force = self.geometry.geodesic_end_vectors(pA, pB)
pO_force = -(pA_force + pB_force)
loads = [
Force(pA, force * pA_force),
Force(pB, force * pB_force),
Force(pO, force * pO_force),
]
return loads
def __repr__(self):
"""Representation of a ``WrappingPathway``."""
attachments = ', '.join(str(a) for a in self.attachments)
return (
f'{self.__class__.__name__}({attachments}, '
f'geometry={self.geometry})'
)
def _point_pair_relative_position(point_1, point_2):
"""The relative position between a pair of points."""
return point_2.pos_from(point_1)
def _point_pair_length(point_1, point_2):
"""The length of the direct linear path between two points."""
return _point_pair_relative_position(point_1, point_2).magnitude()
def _point_pair_extension_velocity(point_1, point_2):
"""The extension velocity of the direct linear path between two points."""
return _point_pair_length(point_1, point_2).diff(dynamicsymbols._t)
|