Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ramp up time default to 0.0 for EndpointForces #106

Closed
Jarvis-X opened this issue Jun 6, 2022 · 2 comments
Closed

Ramp up time default to 0.0 for EndpointForces #106

Jarvis-X opened this issue Jun 6, 2022 · 2 comments
Assignees
Labels
bug Something isn't working invalid This doesn't seem right
Milestone

Comments

@Jarvis-X
Copy link

Jarvis-X commented Jun 6, 2022

Describe the bug
It should be a quick fix: the default value of ramp_up_time=0.0 causes divided-by-zero error when initializing.

To Reproduce

# any rod created for any simulation
mySim.add_forcing_to(rod).using(
EndpointForces, np.array([0, 0, 0]), np.array([-10, 0, 0]))

mySim.finalize()
timestepper = PositionVerlet()

# some time-step related parameters
integrate(timestepper, mySim, final_time, total_steps)
---------------------------------------------------------------------------
ZeroDivisionError                         Traceback (most recent call last)
[<ipython-input-8-285f38790693>](https://localhost:8080/#) in <module>()
    135 # timestepper = PEFRL()
    136 
--> 137 integrate(timestepper, pendulum_sim, final_time, total_steps)
    138 
    139 if PLOT_FIGURE:

4 frames
[/usr/local/lib/python3.7/dist-packages/elastica/timestepper/__init__.py](https://localhost:8080/#) in integrate(StatefulStepper, System, final_time, n_steps, restart_time, progress_bar, **kwargs)
    111 
    112     for i in tqdm(range(n_steps), disable=(not progress_bar)):
--> 113         time = do_step(StatefulStepper, stages_and_updates, System, time, dt)
    114 
    115     print("Final time of simulation is : ", time)

[/usr/local/lib/python3.7/dist-packages/elastica/timestepper/symplectic_steppers.py](https://localhost:8080/#) in do_step(TimeStepper, _steps_and_prefactors, SystemCollection, time, dt)
     89 
     90             # Add external forces, controls etc.
---> 91             SystemCollection.synchronize(time)
     92 
     93             for system in SystemCollection._memory_blocks:

[/usr/local/lib/python3.7/dist-packages/elastica/wrappers/base_system.py](https://localhost:8080/#) in synchronize(self, time)
    157         # Collection call _featuer_group_synchronize
    158         for feature in self._feature_group_synchronize:
--> 159             feature(time)
    160 
    161     def constrain_values(self, time: float):

[/usr/local/lib/python3.7/dist-packages/elastica/wrappers/forcing.py](https://localhost:8080/#) in _call_ext_forces_torques(self, time, *args, **kwargs)
     83     def _call_ext_forces_torques(self, time, *args, **kwargs):
     84         for sys_id, ext_force_torque in self._ext_forces_torques:
---> 85             ext_force_torque.apply_forces(self._systems[sys_id], time, *args, **kwargs)
     86             ext_force_torque.apply_torques(self._systems[sys_id], time, *args, **kwargs)
     87             # TODO Apply torque, see if necessary

[/usr/local/lib/python3.7/dist-packages/elastica/external_forces.py](https://localhost:8080/#) in apply_forces(self, system, time)
    172             self.end_force,
    173             time,
--> 174             self.ramp_up_time,
    175         )
    176 

ZeroDivisionError: division by zero

Environment

  • Python/pip version 21.1.3
  • Numpy/numba version 0.51.2
  • PyElastica version 0.2.3
  • OS, Device Google Colab

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

@Jarvis-X Jarvis-X added the bug Something isn't working label Jun 6, 2022
@skim0119 skim0119 added this to the Version 0.2.4 milestone Jun 7, 2022
@skim0119
Copy link
Collaborator

skim0119 commented Jun 7, 2022

@Jarvis-X Thank you for pointing it out. We'll include the change in the next version v0.2.4.

@skim0119 skim0119 self-assigned this Jun 7, 2022
@skim0119
Copy link
Collaborator

skim0119 commented Jun 8, 2022

The update is included in the update-0.2.4 branch (a511e49)

@skim0119 skim0119 closed this as completed Jun 8, 2022
@skim0119 skim0119 added the invalid This doesn't seem right label Jun 8, 2022
pppprub pushed a commit to pppprub/PyElastica that referenced this issue Sep 4, 2022
* minor grammar fixes in contributing.md
* update publication list

Co-authored-by: Bhosale <[email protected]>
Co-authored-by: Seung Hyun Kim <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants