Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Try to check the validity of the solution

41 views
Skip to first unread message

Guan-Lin Wu

unread,
Nov 15, 2024, 9:17:40 AM11/15/24
to Dedalus Users
Hello everyone,

After solving the equation and export the HDF5 data,
I want to bring the solution back to the original equation to check.
More precisely, I want to check LHS = RHS and relative strength of each term.

However, I don’t know what I should do! I try some Dedalus function, but the equations do not be calculated.

h5_file_path = '/tiara/home/glwu/Dedalus_test/test_HDF5/simulation_data_isoT_add_eq12.h5'
with h5py.File(h5_file_path, 'r') as file:
# 假設 HDF5 檔案中包含三維數據,並且每個變數與變數名稱相符
x = file['x'][:] # x 座標
y = file['y'][:] # y 座標
z = file['z'][:] # z 座標
ug = file['ug'][:] # u 的數值解
vg = file['vg'][:] # v 的數值解
wg = file['wg'][:] # w 的數值解
Pg = file['Pg'][:] # 數值解
Tg = file['Tg'][:] # 數值解
gg = file['gg'][:] # 解析解


# reload data
u['g'] = ug
v['g'] = vg
w['g'] = wg
P['g'] = Pg
T['g'] = Tg



print("==== check eq.10 ====")
# -grav_norm/cs_sq_norm*dlnrhodlnz*w -grav_norm/cs_sq_norm*f*dz(w) + dx(u) + dy(v) = 0
term1_1 = -grav_norm / cs_sq_norm * dlnrhodlnz * w
term1_2 = -grav_norm / cs_sq_norm * f * dz(w)
term1_3 = dx(u)
term1_4 = dy(v)

term1_1_val = term1_1.evaluate()
term1_2_val = term1_2.evaluate()
term1_3_val = term1_3.evaluate()
term1_4_val = term1_4.evaluate()

(above is some of my code, or you can see the full version in attachment.)

Please give me some advise! Thank you!


check.py
截圖 2024-11-15 上午11.34.48.png

Keaton Burns

unread,
Nov 18, 2024, 8:49:50 AM11/18/24
to dedalu...@googlegroups.com
Hello,

When you evaluate a Dedalus expression, you get back a field object storing the result. If you print the field object, you are just printing its name, which is by default the text string that defines the expression. If you want to print the grid or coefficient values of the field, you need to use [‘g’] or [‘c’] to get that data from the field object. Please take a look at the tutorial notebook on field objects for more.

Best,
-Keaton

--
You received this message because you are subscribed to the Google Groups "Dedalus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dedalus-user...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/dedalus-users/21a01212-8852-4551-8ba5-e878b379b179n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages