@@ -453,7 +453,8 @@ def ArgoVerticalMovement(particle, fieldset, time):
453453 if particle .cycle_phase == 0 :
454454 # Phase 0: Sinking with vertical_speed until depth is driftdepth
455455 particle_ddepth += fieldset .vertical_speed * particle .dt
456- if particle .depth >= fieldset .driftdepth :
456+ if particle .depth + particle_ddepth >= fieldset .driftdepth :
457+ particle_ddepth = fieldset .driftdepth - particle .depth
457458 particle .cycle_phase = 1
458459
459460 elif particle .cycle_phase == 1 :
@@ -466,15 +467,16 @@ def ArgoVerticalMovement(particle, fieldset, time):
466467 elif particle .cycle_phase == 2 :
467468 # Phase 2: Sinking further to maxdepth
468469 particle_ddepth += fieldset .vertical_speed * particle .dt
469- if particle .depth <= fieldset .maxdepth :
470+ if particle .depth + particle_ddepth <= fieldset .maxdepth :
471+ particle_ddepth = fieldset .maxdepth - particle .depth
470472 particle .cycle_phase = 3
471473
472474 elif particle .cycle_phase == 3 :
473475 # Phase 3: Rising with vertical_speed until at surface
474476 particle_ddepth -= fieldset .vertical_speed * particle .dt
475477 particle .cycle_age += particle .dt # solve issue of not updating cycle_age during ascent
476- if particle .depth >= fieldset .mindepth :
477- particle . depth = fieldset .mindepth
478+ if particle .depth + particle_ddepth >= fieldset .mindepth :
479+ particle_ddepth = fieldset .mindepth - particle . depth
478480 particle .temperature = math .nan # reset temperature to NaN at end of sampling cycle
479481 particle .salinity = math .nan # idem
480482 particle .cycle_phase = 4
0 commit comments