-
Notifications
You must be signed in to change notification settings - Fork 4
WIP: Python backend. First commit #33
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
base: master
Are you sure you want to change the base?
Conversation
…O DC, NO ARTIFICIAL DISSIPATION
|
I will have a look at this in this week. |
python/InductionEq.py
Outdated
| if I_Tech['REAL'] == 'float': | ||
| field_u_init = np.zeros((4, I_Tech['num_nodes_pad']), dtype=np.float32) | ||
| field_b_init = np.zeros((4, I_Tech['num_nodes_pad']), dtype=np.float32) | ||
| field_rho_init = np.zeros((1, I_Tech['num_nodes_pad']), dtype=np.float32)+1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
np.ones
ranocha
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should use either spaces (preferred) or tabs.
python/InductionEq.py
Outdated
| I_Mesh['DX'] = DX; I_Mesh['DY'] = DY; I_Mesh['DZ'] = DZ; | ||
| num_nodes = I_Mesh['NODES_X']*I_Mesh['NODES_Y']*I_Mesh['NODES_Z']; | ||
|
|
||
| # later ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO
python/InductionEq.py
Outdated
| 'L2error_B': L2error_B, \ | ||
| 'L2error_divB': L2error_divB} | ||
| else: | ||
| print('Wrong value of time_integrator_num_fields =' + str( time_integrator_num_fields)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should throw an exception.
python/cl.py
Outdated
| global program, ctx | ||
| src = ' ' | ||
| for entry in src_path: | ||
| file = open(entry, 'r') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be better to use something along the lines of
with open( entry, 'r') as io:
src = src + io.read()
python/compute_error_rotation_2d.py
Outdated
| #variables, e.g. stepsize, timestep, local work group size, etc... | ||
| (field_b_init, field_u_init, field_rho_init) = induction_eq.initialize(); | ||
|
|
||
| print('Testcase: ' + I_RunOps['testcase'] +'\n') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since python3 adds a newline for every print, the \n is not necessary.
|
You seem to use |
|
The temporary python files should be added to |
|
The comments above are just some random thoughts I had while reading the code. |
|
The semicolons are superflous and ugly (at least for me). |
|
During some simple tests, there are no segfaults for me on an NVidia GPU but on an Intel CPU: This seems to be due to up to now hardcoded choice of some parameters. |
|
There are also some differences in the results (divergence norm, total energy, relative error) of the python version and the matlab version (starting at the first or second significant digit). This is a bit strange since we didn't experience such differences with various hardware and software configurations before, both for matlab and julia. |
…ts#33. Added the timer and OpenCl device querry from the matlab version. found a bug from Fortran vs C array indexing
|
I changed most things, but the Python2 exception doesn't work because the interpreter crashes too early. I think i found the bug which changed the results. The calculation of DT gave different results on different machines because i didn't know that Matlab uses Fortran and one based indexing |
This sounds good. I will test it later. Since this PR is mainly used by you, you can simply stick to python3 and everything is fine. |
|
The errors seem to fit now (only the last ~5 digits are different). |
This is a alpha of the Python backend. It uses PyOpenCl as OpenCL interface and should work like the normal MatLab backend, but with a device selection menu. Only the SSPRK33 timeintegrator is ready and all extras like divergence cleaning and artificial dissipation are missing. I plan to split InductionEq.py into several Files as a next assignment.