You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For restarting a simulation we load the data of the previous simulation using the following load_state function. This function behaves expectedly for straight rods. However, for ring rods since they have periodic boundaries at the ends these boundaries have to by synched by calling the constrain functions. Thus, after loading the states we need to call the boundary conditions before starting integration.
"Restart time of loaded rods are different, check your inputs!"
)
ifverbose:
print("Load complete: {}".format(directory))
returntime_list[0]
Following changes will fix the issue.
defload_state(simulator, directory: str="", verbose: bool=False):
""" Load the rod-state. Compatibale with 'save_state' method. If the save-file does not exist, it returns error. Call this function after finalize method. Parameters ---------- simulator : object Simulator object. directory : str Directory path name. verbose : boolean Returns ------ time : float Simulation time of systems when they are saved. """time_list= [] # Simulation time of rods when they are saved. foridx, rodinenumerate(simulator):
ifisinstance(rod, MemoryBlockCosseratRod) orisinstance(
rod, MemoryBlockRigidBody
):
continuepath=os.path.join(directory, "system_{}.npz".format(idx))
data=np.load(path, allow_pickle=True)
forkey, valueindata.items():
ifkey=="time":
time_list.append(value.item())
continueifvalue.shape!= ():
# Copy data into placeholders getattr(rod, key)[:] =valueelse:
# For single-value data setattr(rod, key, value)
ifnotall_equal(time_list):
raiseValueError(
"Restart time of loaded rods are different, check your inputs!"
)
# Apply boundary conditions. Ring rods have periodic BC, so we need to update periodic elements in memory blockself.simulator.constrain_values(time)
# Damping is also part of constrains, so we need to distinguish BC and damping.forfeatureinself.simulator._feature_group_constrain_rates:
iffeature.__name__=="_constrain_rates":
feature(time)
ifverbose:
print("Load complete: {}".format(directory))
returntime
We also need to add relevant test cases, to test if ring rods are loaded correctly.
The text was updated successfully, but these errors were encountered:
For restarting a simulation we load the data of the previous simulation using the following
load_state
function. This function behaves expectedly for straight rods. However, for ring rods since they have periodic boundaries at the ends these boundaries have to by synched by calling the constrain functions. Thus, after loading the states we need to call the boundary conditions before starting integration.PyElastica/elastica/restart.py
Lines 56 to 103 in cf862d0
Following changes will fix the issue.
We also need to add relevant test cases, to test if ring rods are loaded correctly.
The text was updated successfully, but these errors were encountered: