Skip to content

GroundMotionManager

GroundMotionManager

GroundMotionManager(mesh_maker: Model, time_series_manager=None)

Manager for a local collection of ground motions.

The manager is responsible for ground-motion lifecycle and numbering: adding instances, assigning tags, looking up objects, deleting objects, and retagging after removals or tag-start changes. It is intentionally not a singleton. Each GroundMotionManager instance owns an independent tag space, which allows future model or Model instances to keep local ground-motion collections.

Concrete ground-motion classes validate and render themselves, while this manager controls ownership. Prefer factory methods such as plain(...) and interpolated(...) for normal use; use add(...) when an instance has already been constructed manually.

Example
from femora.core.model import Model

model = Model()
accel = model.time_series.path(dt=0.01, filePath="support.acc")
disp = model.time_series.path(dt=0.01, filePath="support.disp")

gm = model.ground_motion.plain(accel=accel, disp=disp)
print(gm.tag)      # 1
print(gm.to_tcl()) # groundMotion 1 Plain -accel ... -disp ...

Create an empty ground-motion manager with tags starting at 1.

Attributes

_mesh_maker instance-attribute

_mesh_maker = mesh_maker

_ground_motions instance-attribute

_ground_motions: Dict[int, GroundMotion] = {}

_start_tag instance-attribute

_start_tag = 1

_tagging instance-attribute

_tagging = CompactRetagPolicy[GroundMotion]()

_time_series_manager instance-attribute

_time_series_manager = time_series_manager

Methods:

__len__

__len__() -> int

Return the number of managed ground motions.

__iter__

__iter__() -> Iterator[GroundMotion]

Iterate over managed ground motions in tag order.

add

add(ground_motion: GroundMotion) -> GroundMotion

Add a ground motion instance and assign its local tag.

Parameters:

Name Type Description Default
ground_motion GroundMotion

Unmanaged GroundMotion instance to store.

required

Returns:

Type Description
GroundMotion

The same ground-motion instance, now tagged and managed.

Raises:

Type Description
TypeError

If ground_motion is not a GroundMotion.

ValueError

If ground_motion belongs to another manager or its preassigned tag conflicts with another object managed here.

plain

plain(accel: Optional[TimeSeries] = None, vel: Optional[TimeSeries] = None, disp: Optional[TimeSeries] = None, integrator: Optional[str] = None, integrator_args: Optional[List[Union[int, float, str]]] = None, factor: float = 1.0) -> PlainGroundMotion

Create, tag, and store a PlainGroundMotion.

Parameters:

Name Type Description Default
accel Optional[TimeSeries]

Acceleration time series. Optional if vel or disp is provided.

None
vel Optional[TimeSeries]

Velocity time series. Optional if accel or disp is provided.

None
disp Optional[TimeSeries]

Displacement time series. Optional if accel or vel is provided.

None
integrator Optional[str]

Optional OpenSees integration method, such as "Trapezoidal" or "Simpson".

None
integrator_args Optional[List[Union[int, float, str]]]

Optional arguments appended after integrator in the -int option.

None
factor float

Constant scale factor for the ground motion.

1.0

Returns:

Type Description
PlainGroundMotion

The managed PlainGroundMotion instance.

interpolated

interpolated(ground_motions: List[GroundMotion], factors: List[float]) -> InterpolatedGroundMotion

Create, tag, and store an InterpolatedGroundMotion.

Parameters:

Name Type Description Default
ground_motions List[GroundMotion]

Ground motions to combine. Each item must be a GroundMotion instance.

required
factors List[float]

Interpolation factors. Must have the same length as ground_motions.

required

Returns:

Type Description
InterpolatedGroundMotion

The managed InterpolatedGroundMotion instance.

get

get(tag: int) -> GroundMotion

Return a managed ground motion by tag.

Parameters:

Name Type Description Default
tag int

Ground-motion tag in this manager's local tag space.

required

Raises:

Type Description
KeyError

If no ground motion exists with tag.

get_all

get_all() -> Dict[int, GroundMotion]

Return a copy of all managed ground motions keyed by tag.

remove

remove(tag: int) -> None

Remove a ground motion and retag remaining instances.

Parameters:

Name Type Description Default
tag int

Ground-motion tag to remove. Missing tags are ignored.

required

clear

clear() -> None

Remove all ground motions and clear their assigned tags.

set_tag_start

set_tag_start(start_tag: int) -> None

Set the first tag and retag existing ground motions.

Parameters:

Name Type Description Default
start_tag int

First tag to use for this manager. Must be positive.

required

Raises:

Type Description
ValueError

If start_tag is less than 1.

_next_available_tag

_next_available_tag() -> int

Return the next unused tag in this manager's local tag space.

_reassign_tags

_reassign_tags() -> None

Retag all managed ground motions from _start_tag in tag order.

_validate_dependencies

_validate_dependencies(ground_motion: GroundMotion) -> None

Ensure a ground motion only references local managed dependencies.