underworldcode / underworld2

underworld2: A parallel, particle-in-cell, finite element code for Geodynamics.
http://www.underworldcode.org/
Other
168 stars 58 forks source link

Temperature difference between two steps does not decrease with reducing step interval #653

Open tingyang2004 opened 1 year ago

tingyang2004 commented 1 year ago

Hi all,

I ran into a strange issue when I tried to track the temperature evolution of a continental rifting model. As shown in the script below, I ran the advection-diffusion equation (SUPG) five times with the same velocity and initial temperature fields, as well as the same temperature's time derivative, each time with dt being 0.5 times the previous one. I expected the maximum temperature difference from the initial temperature field to decrease with reducing dt, but the output (elements of max_dT_Array) does not show this trend. Do you know why this happens? Thanks a lot.

Ting

Script to calculate temperature evolution and record maximum temperature difference: image

output: image

julesghub commented 1 year ago

Hi Ting, I think the following line is the problem if its == dT_maxIts - 1:

It will only fire when its == 4, which is what your output shows.

tingyang2004 commented 1 year ago

Thanks, Julian. You are right, this coding mistake occurred when I tried to simplify the original script. However, this 'temperature difference does not decrease with reducing step interval' issue persists even when this coding mistake is corrected. See screenshots below.

image

image

tingyang2004 commented 1 year ago

The three columns of max_dT_Array in the standard output are iteration (its), dt, and dT_max, respectively.

julesghub commented 1 year ago

In the code every iteration is using a different initial temperature and temperatureDot. This isn't what you want right?

tingyang2004 commented 1 year ago

I thought it is the same initial temperature and temperatureDot. Since I used temperatureField.data[:] = T_old.data[:] temperatureDotField.data[:] = Tdot_old.data[:]

to reset the temperature after each iteration.

julesghub commented 1 year ago

oh I see. Why don't you create fields temperature0 and temperatureDot0 for the initial conditions. Just to ensure you don't have to write over the numpy arrays.

tingyang2004 commented 1 year ago

How do I create and temperatureDot0 for the initial conditions?

julesghub commented 1 year ago

The initial values of temperatureDot0 should always be zero. So I suggest using temperatureDot0.data[:] = 0 in the loop.

tingyang2004 commented 1 year ago

temperature reset in the while loop is changed as below: temperatureField.data[:] = T_old.data[:] temperatureDotField.data[:] = 0.0 #Tdot_old.data[:]

The temperature difference is as below, it does not show any dependence on dt. image

At an earlier step, the temperature difference does reduce with reducing dt. image

julesghub commented 1 year ago

Instead of doing T_old = temperatureField.copy() Can you make T_old a new mesh variable, i.e. T_old = mesh.add_variable(....)

I think the copy() is not a 'deep' copy and is potentially causing the issue.

tingyang2004 commented 1 year ago

creating a new mesh variable for T_old does not make any difference. Values of the derived dT_max are exactly the same as before.

julesghub commented 1 year ago

Can you upload a version of the model file and I can look at it more closely. The easiest way would be to make a private github repo and invite me to it. Remember to let me know the version of the code you're using.

tingyang2004 commented 1 year ago

OK, I will do that.

tingyang2004 commented 1 year ago

Hi Julian, I have invited you to my temporal repository. The swarm file exceeds the 25 Mb limit, so I shared it using my net-disk. You can download it through the link in README.md. Thanks!

julesghub commented 1 year ago

@tingyang2004 Could you re-invite me to the repo - unfortunately the invitation expired. opps

tingyang2004 commented 1 year ago

re-invited @julesghub