_fill_fields raise RuntimeError in Derived fields
Hi Everyone, I met RuntimeError when I tried to plot Derived fields, such as vorticity field derived from velocity field It seems that "tot" calculated from the function "fill_region" raising the "RuntimeError" (See the corresponding yt source code part below) I wonder how to fix up this error and will appreciate if anyone can help me~ -------------------------------------------------------- Here is the plotting vorticity field code PART ONE function 144 def vort_z_func(field, data): 145 return ( 146 + data['boxlib', 'v_gradient_x'] 147 - data['boxlib', 'u_gradient_y'] 148 ) PART TWO main 59 u_gradient = ds.add_gradient_fields(("boxlib","u")) 60 v_gradient = ds.add_gradient_fields(("boxlib","v")) 61 62 derived_fields = [ # field name, units, displayname 63 ('vort_z', '1 / cm', 'Vorticity in z direction') 64 ] 65 for name, unitstr, dispname in derived_fields: 66 ds.add_field( 67 ('boxlib', name), 68 units = unitstr, 69 function = eval(name + '_func'), 70 sampling_type = 'cell', 71 display_name = dispname 72 ) 73 ds.periodicity = (True, True, True) 74 slc = yt.SlicePlot(ds, 'z', 'vort_z', width=((chang,'cm'),(kuan,'cm')),center=([xcent,ycent,0.001],'cm')) -------------------------------------------------------------------------------------------------- Here is the error info: 1084 File "vorfield.py", line 143, in <module> 1085 slc = yt.SlicePlot(ds, 'z', 'vort_z', width=((chang,'cm'),(kuan,'cm')),center=([xcent,ycent,0.001],'cm')) 1086 File "/WORK/anaconde/envs/test/lib/python3.8/site-packages/yt/visualization/plot_window.py", line 1986, in SlicePlot 1087 return AxisAlignedSlicePlot(ds, normal, fields, *args, **kwargs) 1088 File "/WORK/anaconde/envs/test/lib/python3.8/site-packages/yt/visualization/plot_window.py", line 1282, in __init__ 1089 slc.get_data(fields) 1090 File "/WORK/anaconde/envs/test/lib/python3.8/site-packages/yt/data_objects/data_containers.py", line 1583, in get_data 1091 self._generate_fields(fields_to_generate) 1092 File "/WORK/anaconde/envs/test/lib/python3.8/site-packages/yt/data_objects/data_containers.py", line 1603, in _generate_fields 1093 fd = self._generate_field(field) 1094 File "/WORK/anaconde/envs/test/lib/python3.8/site-packages/yt/data_objects/data_containers.py", line 293, in _generate_field 1095 tr = self._generate_fluid_field(field) 1096 File "/WORK/anaconde/envs/test/lib/python3.8/site-packages/yt/data_objects/data_containers.py", line 311, in _generate_fluid_field 1097 rv = self._generate_spatial_fluid(field, ngt_exception.ghost_zones) 1098 File "/WORK/anaconde/envs/test/lib/python3.8/site-packages/yt/data_objects/data_containers.py", line 341, in _generate_spatial_fluid 1099 gz[field][ngz:-ngz, ngz:-ngz, ngz:-ngz], 1100 File "/WORK/anaconde/envs/test/lib/python3.8/site-packages/yt/data_objects/data_containers.py", line 256, in __getitem__ 1101 self.get_data(f) 1102 File "/WORK/anaconde/envs/test/lib/python3.8/site-packages/yt/data_objects/construction_data_containers.py", line 691, in get_data 1103 if len(fill) > 0: self._fill_fields(fill) 1104 File "/WORK/anaconde/envs/test/lib/python3.8/site-packages/yt/data_objects/construction_data_containers.py", line 1060, in _fill_fields 1105 raise RuntimeError --------------------------------------------------------------------------------------------------- Here is the corresponding yt source code part 1053 for chunk in ls.data_source.chunks(fields, "io"): 1054 chunk[fields[0]] 1055 input_fields = [chunk[field] for field in fields] 1056 tot -= fill_region(input_fields, ls.fields, ls.current_level, 1057 ls.global_startindex, chunk.icoords, 1058 chunk.ires, domain_dims, refine_by) 1059 if level == 0 and tot != 0: 1060 raise RuntimeError 1061 self._update_level_state(ls) Best wishes, He Yifeng
participants (1)
-
hyf@stu.pku.edu.cn