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

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

Open
tingyang2004 opened this issue Feb 24, 2023 · 16 comments

Comments

@tingyang2004
Copy link

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
Copy link
Member

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
Copy link
Author

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
Copy link
Author

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

@julesghub
Copy link
Member

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

@tingyang2004
Copy link
Author

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
Copy link
Member

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
Copy link
Author

How do I create and temperatureDot0 for the initial conditions?

@julesghub
Copy link
Member

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

@tingyang2004
Copy link
Author

tingyang2004 commented Feb 28, 2023

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
Copy link
Member

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
Copy link
Author

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
Copy link
Member

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
Copy link
Author

OK, I will do that.

@tingyang2004
Copy link
Author

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
Copy link
Member

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

@tingyang2004
Copy link
Author

re-invited @julesghub

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants