Hi Barry,

The code had a different behavior at one point (using the initial timestep 
after an event) : I still use commit f0e947c45e099a328e78b13737aa9bc4c143ca79 
when I really need the time step to get really small after an event. I don't 
know if it can help with the current code.

Best,

Sophie
________________________________
From: Barry Smith <[email protected]>
Sent: Tuesday, October 27, 2020 16:24
To: Blondel, Sophie <[email protected]>
Cc: Matthew Knepley <[email protected]>; [email protected] 
<[email protected]>; [email protected] 
<[email protected]>
Subject: Re: [petsc-users] TSSetEventHandler and TSSetPostEventIntervalStep


  I'm sorry the code is still fundamentally broken, I know I promised a long 
time ago to fix it all up but it is actually pretty hard to get right.

  It detects the zero by finding a small value when it should detect it by find 
a small region where it changes sign but surprising it is so hardwired
to the size test that fixing it and testing the new code has been very 
difficult to me.  My branch is barry/2019-08-18/fix-tsevent-posteventdt

  Barry



On Oct 27, 2020, at 3:02 PM, Blondel, Sophie via petsc-users 
<[email protected]<mailto:[email protected]>> wrote:

Hi Matt,

With the ex40 I attached in my previous email here is what I get printed on 
screen when running "./ex40 -ts_monitor -ts_event_monitor":
0 TS dt 0.1 time 0.
1 TS dt 0.5 time 0.1
2 TS dt 0.5 time 0.6
3 TS dt 0.5 time 1.1
4 TS dt 0.5 time 1.6
5 TS dt 0.5 time 2.1
6 TS dt 0.5 time 2.6
7 TS dt 0.5 time 3.1
8 TS dt 0.5 time 3.6
9 TS dt 0.5 time 4.1
10 TS dt 0.5 time 4.6
11 TS dt 0.5 time 5.1
12 TS dt 0.5 time 5.6
13 TS dt 0.5 time 6.1
14 TS dt 0.5 time 6.6
15 TS dt 0.5 time 7.1
TSEvent: Event 0 zero crossing at time 7.6 located in 0 iterations
Ball hit the ground at t =  7.60 seconds
16 TS dt 0.5 time 7.6
17 TS dt 0.5 time 8.1
18 TS dt 0.5 time 8.6
19 TS dt 0.5 time 9.1
20 TS dt 0.5 time 9.6
21 TS dt 0.5 time 10.1
22 TS dt 0.5 time 10.6
23 TS dt 0.5 time 11.1
24 TS dt 0.5 time 11.6
25 TS dt 0.5 time 12.1
26 TS dt 0.5 time 12.6
27 TS dt 0.5 time 13.1
28 TS dt 0.5 time 13.6
29 TS dt 0.5 time 14.1
30 TS dt 0.5 time 14.6
31 TS dt 0.5 time 15.1
32 TS dt 0.5 time 15.6
33 TS dt 0.5 time 16.1
34 TS dt 0.5 time 16.6
35 TS dt 0.5 time 17.1
36 TS dt 0.5 time 17.6
37 TS dt 0.5 time 18.1
38 TS dt 0.5 time 18.6
39 TS dt 0.5 time 19.1
40 TS dt 0.5 time 19.6
41 TS dt 0.5 time 20.1
42 TS dt 0.5 time 20.6
43 TS dt 0.5 time 21.1
44 TS dt 0.5 time 21.6
45 TS dt 0.5 time 22.1
46 TS dt 0.5 time 22.6
47 TS dt 0.5 time 23.1
48 TS dt 0.5 time 23.6
49 TS dt 0.5 time 24.1
50 TS dt 0.5 time 24.6
51 TS dt 0.5 time 25.1
TSEvent: Event 0 zero crossing at time 25.6 located in 0 iterations
Ball hit the ground at t = 25.60 seconds
52 TS dt 0.5 time 25.6
53 TS dt 0.5 time 26.1
54 TS dt 0.5 time 26.6
55 TS dt 0.5 time 27.1
56 TS dt 0.5 time 27.6
57 TS dt 0.5 time 28.1
58 TS dt 0.5 time 28.6
59 TS dt 0.5 time 29.1
60 TS dt 0.5 time 29.6
61 TS dt 0.5 time 30.1
0 TS dt 0.1 time 0.
1 TS dt 0.5 time 0.1
2 TS dt 0.5 time 0.6
3 TS dt 0.5 time 1.1
4 TS dt 0.5 time 1.6
5 TS dt 0.5 time 2.1
6 TS dt 0.5 time 2.6
7 TS dt 0.5 time 3.1
8 TS dt 0.5 time 3.6
9 TS dt 0.5 time 4.1
10 TS dt 0.5 time 4.6
11 TS dt 0.5 time 5.1
12 TS dt 0.5 time 5.6
13 TS dt 0.5 time 6.1
14 TS dt 0.5 time 6.6
15 TS dt 0.5 time 7.1
16 TS dt 0.5 time 7.6
17 TS dt 0.5 time 8.1
18 TS dt 0.5 time 8.6
19 TS dt 0.5 time 9.1
20 TS dt 0.5 time 9.6
21 TS dt 0.5 time 10.1
22 TS dt 0.5 time 10.6
23 TS dt 0.5 time 11.1
24 TS dt 0.5 time 11.6
25 TS dt 0.5 time 12.1
26 TS dt 0.5 time 12.6
TSEvent: Event 0 zero crossing at time 13.1 located in 0 iterations
Ball hit the ground at t = 13.10 seconds
27 TS dt 0.5 time 13.1
28 TS dt 0.5 time 13.6
29 TS dt 0.5 time 14.1
30 TS dt 0.5 time 14.6
31 TS dt 0.5 time 15.1
32 TS dt 0.5 time 15.6
33 TS dt 0.5 time 16.1
34 TS dt 0.5 time 16.6
35 TS dt 0.5 time 17.1
36 TS dt 0.5 time 17.6
37 TS dt 0.5 time 18.1
38 TS dt 0.5 time 18.6
39 TS dt 0.5 time 19.1
40 TS dt 0.5 time 19.6
41 TS dt 0.5 time 20.1
42 TS dt 0.5 time 20.6
43 TS dt 0.5 time 21.1
44 TS dt 0.5 time 21.6
45 TS dt 0.5 time 22.1
46 TS dt 0.5 time 22.6
47 TS dt 0.5 time 23.1
TSEvent: Event 0 zero crossing at time 23.6 located in 0 iterations
Ball hit the ground at t = 23.60 seconds
48 TS dt 0.5 time 23.6
49 TS dt 0.5 time 24.1
50 TS dt 0.5 time 24.6
51 TS dt 0.5 time 25.1
52 TS dt 0.5 time 25.6
53 TS dt 0.5 time 26.1
TSEvent: Event 0 zero crossing at time 26.6 located in 0 iterations
Ball hit the ground at t = 26.60 seconds
54 TS dt 0.5 time 26.6
55 TS dt 0.5 time 27.1
56 TS dt 0.5 time 27.6
57 TS dt 0.5 time 28.1
58 TS dt 0.5 time 28.6
59 TS dt 0.5 time 29.1
60 TS dt 0.5 time 29.6
61 TS dt 0. time 30.1

I don't see the 0.001 timestep here, do you get a different behavior?

Thank you,

Sophie
________________________________
From: Matthew Knepley <[email protected]<mailto:[email protected]>>
Sent: Tuesday, October 27, 2020 15:34
To: Blondel, Sophie <[email protected]<mailto:[email protected]>>
Cc: [email protected]<mailto:[email protected]> 
<[email protected]<mailto:[email protected]>>; 
[email protected]<mailto:[email protected]>
 
<[email protected]<mailto:[email protected]>>
Subject: Re: [petsc-users] TSSetEventHandler and TSSetPostEventIntervalStep


[External Email]

On Tue, Oct 27, 2020 at 3:09 PM Blondel, Sophie via petsc-users 
<[email protected]<mailto:[email protected]>> wrote:
Hi,

I am currently using TSSetEventHandler in my code to detect a random event 
where the solution vector gets modified during the event. Ideally, after the 
event happens I want the solver to use a much smaller timestep using 
TSSetPostEventIntervalStep. However, when I use TSSetPostEventIntervalStep the 
solver doesn't use the set value. I managed to reproduce the behavior by 
modifying ex40.c as attached.

 I stepped through ex40, and it does indeed change the timestep to 0.001. Can 
you be more specific, perhaps with monitors, about what you think is wrong?

  Thanks,

     Matt

I think the issue is related to the fact that the fvalue is not technically 
"approaching" 0 with a random event, it is more of a step function instead. Do 
you have any recommendation on how to implement the behavior I'm looking for? 
Let me know if I can provide additional information.

Best,

Sophie


--
What most experimenters take for granted before they begin their experiments is 
infinitely more interesting than any results to which their experiments lead.
-- Norbert Wiener

https://www.cse.buffalo.edu/~knepley/<http://www.cse.buffalo.edu/~knepley/>

Reply via email to