Skip to content

Commit effcbac

Browse files
Merge pull request #922 from kaelyndunnell/fix-timestep-bug
Fix timestep bug
2 parents a3b1254 + 933650d commit effcbac

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

src/festim/stepsize.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def modify_value(self, value, nb_iterations, t=None):
141141
if updated_value > time_to_milestone and not np.isclose(
142142
t, next_milestone, atol=0
143143
):
144-
updated_value = next_milestone
144+
updated_value = time_to_milestone
145145

146146
return updated_value
147147

test/test_stepsize.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -169,23 +169,21 @@ def test_next_milestone(milestones, current_time, expected_value):
169169
assert expected_value == next_milestone
170170

171171

172-
def test_overshoot_milestone(nb_its=1, target=4):
172+
def test_overshoot_milestone():
173173
"""Test that stepsize is modified
174174
when going to overshoot a milestone.
175175
"""
176176

177177
my_stepsize = F.Stepsize(initial_value=0.1)
178-
my_stepsize.growth_factor = 2.0
179-
my_stepsize.target_nb_iterations = target
178+
my_stepsize.growth_factor = 1
179+
my_stepsize.target_nb_iterations = 4
180180

181181
my_stepsize.milestones = [1.3]
182182

183-
current_value = 0.5
184-
new_value = my_stepsize.modify_value(
185-
value=current_value, nb_iterations=nb_its, t=0.9
186-
)
183+
current_value = 100000
184+
new_value = my_stepsize.modify_value(value=current_value, nb_iterations=1, t=1)
187185

188-
expected_value = 1.3
186+
expected_value = 1.3 - 1
189187

190188
assert new_value == expected_value
191189

0 commit comments

Comments
 (0)