{"id":13444234,"url":"https://github.com/thomas-schweich/CADPotential","last_synced_at":"2025-03-20T18:31:36.693Z","repository":{"id":83429515,"uuid":"99850189","full_name":"thomas-schweich/CADPotential","owner":"thomas-schweich","description":"Massively Parallel Gravitational Potential Calculator and Voxelizer Python Interface","archived":false,"fork":false,"pushed_at":"2017-09-23T16:30:47.000Z","size":3326,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-08-01T03:46:13.073Z","etag":null,"topics":["cad","electric-potential","gravitational-potential","massively-parallel","obj","opencl","physics","physics-simulation","potentials","pyopencl","voxelizer"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thomas-schweich.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-08-09T20:29:22.000Z","updated_at":"2019-10-08T17:23:41.000Z","dependencies_parsed_at":"2023-09-30T01:04:17.166Z","dependency_job_id":null,"html_url":"https://github.com/thomas-schweich/CADPotential","commit_stats":{"total_commits":17,"total_committers":1,"mean_commits":17.0,"dds":0.0,"last_synced_commit":"97fed17eb5c7f3b2c4a1072c1067b14851463c90"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomas-schweich%2FCADPotential","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomas-schweich%2FCADPotential/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomas-schweich%2FCADPotential/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomas-schweich%2FCADPotential/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thomas-schweich","download_url":"https://codeload.github.com/thomas-schweich/CADPotential/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221792892,"owners_count":16881289,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cad","electric-potential","gravitational-potential","massively-parallel","obj","opencl","physics","physics-simulation","potentials","pyopencl","voxelizer"],"created_at":"2024-07-31T03:02:22.576Z","updated_at":"2024-10-28T06:30:24.671Z","avatar_url":"https://github.com/thomas-schweich.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# Load OBJ File Voxelizations and Quickly Analyze Gravitational Potentials\n\nThomas Schweich, GEE Lab at Washington University in St. Louis. MIT License.\n\nThe repository serves two purposes, as:\n\n- A clean and efficient Python interface to files created by Dan Morris' [Voxelizer](http://dmorris.net/projects/voxelizer/).\n- A massively parallel gravitational potential calculator for arbitrary 3d point matrices (which can be easily modified to serve\n  as an electric potential calculator) using OpenCL and PyOpenCL.\n\nSource code relating to the former is stored in the *voxel* directory, while source relating to the latter is stored in the\n*main* directory.\n\n## As a Python Interface to Dan Morris' [Voxelizer](http://dmorris.net/projects/voxelizer/)\n\n### load_voxels.py\n\nRunning the script from the command line provides options for loading a single .voxels file or multiple files, indicated\nby a file glob (using * as a wildcard), into a single `Voxels` Python object.\nThe script retains all information in the file(s) except the file header(s).\nThe script can be run interactively, in which case the Voxels object resulting from the loaded file(s) can be accessed\nthrough a variable called 'voxels', such as in the following example:\n\n```\n$ python -i load_voxels.py myvoxels_*.voxels\n\u003e\u003e\u003e voxels.to_set()\n{(0, 0, 0), (0, 1, 0) ... }\n\u003e\u003e\u003e first_voxel = voxels.get_all_voxels()[0]\n\u003e\u003e\u003e first_voxel\n\u003c__main__.VoxelfileVoxel object at 0x0000000006A3FEC8\u003e\n\u003e\u003e\u003e first_voxel.i\n0\n\u003e\u003e\u003e first_voxel.has_normal\n1\n\u003e\u003e\u003e voxels.plot_graph()\n# Graph appears\n# etc...\n```\n\nwhere 'myvoxels_1.voxels', 'myvoxels_2.voxels'... are the names of your .voxels files.\n\nThe set resulting from the call to `voxels.to_set()` would contain the positions of each voxel from the file.\nThe VoxelfileVoxel object resulting from `voxels.voxels[0]` would be the first voxel in the file.\n`ipython` could also be used in place of `python`. The dollar-sign (`$`) is simply meant to indicate that the proceeding\nline is entered into a console (whose working directory is the one containing the script).\n\nUse `$ python load_voxels.py -h` for help. The module may also, of course, simply be imported by other scripts.\nThe Voxels object also contains methods for dealing with the concatenation of multiple .voxels files into a single\nobject. This is due to the fact that the script was originally written for use with the voxelization of a complex CAD\nfile which was divided into many small components. As a result, the script would theoretically work with multiple\nobjects as well.\n\nThe script has been tested to run relatively fluently with multi-million-voxel files, including plotting. The test was\nrun on a laptop with a 2 core, 4 thread Intel i5 processor with 8GB RAM. Performance likely scales quite well with\nimproved hardware.\n\nThe module can also be imported and used in other programs.\n\n### Other scripts\n\nScripts can be found in the *voxels* directory which serve the following purposes:\n\n- Breaking apart a blender object into its component parts\n- Combining a group of voxel files within a directory\n- Repeatedly invoking the Voxelizer program on a directory of objects, and\n- Detecting suspicious voxelizations\n\nThese are more one-off style scripts that will need to be modified to suit your needs.\n\n\n## As a Massively Parallel Potential Calculator\n\n### calculate_potentials.py\n\nThe important function contained in this file is `calculate_potentials_opencl`, along with its helper function `generate_opencl_objects`.\n  The `generate_opencl_objects` takes the following parameters:\n  - A 2d array of 3-vectors representing each point at which you would like the gravitational potential\n  - A 2d array of 3-vectors representing each point of mass you would like to be accounted for in the calculations\n  \n The `calculate_potentials_opencl` function takes the following parameters:\n  - The result of your call to `generate_opencl_objects`\n  - The mass density of the volume matrix material\n  - The mass density of the mass matrix material\n\nA function `plot_results` uses PyQTGraph to plot two resulting matrices, with the resulting potentials used as a color scale from\nblue (low) to red (high). The module also contains functions for generating example spaces. By default, running the file will generate\nan expansive universe of point masses with a cube matrix in the middle for which potential values are calculated. With reasonably new\nhardware, despite being an O(n^2) operation, many points can be calculated *very* quickly.\n\n### kernel_test.py\n\nThis file simply proves the accuracy of the calculation when compared to a similar calculation made using NumPy as well as rote Python.\nEquality assertions are made, so if the script runs successfully your GPU (or other OpenCL device) has arrived at the same conclusion\nas your CPU.\n\n### potential_kernel.cl\n\nThe file contains the actual kernel used to calculate the gravitational potentials with OpenCL. The value of G could be changed to\nCoulomb's Constant and electric charge could be used in place of mass to calculate electric potentials.\n\n\n## Use in Conjunction\n\nAn arbitrary experimental apparatus and volume may be input into the voxelizing module, with the output of a call to `to_ndarray()`\nfed into the potential calculation module in order to obtain the potential analysis of a scientific experiment. This was the original\nintention of the project.\n\n## License\n\nCopyright 2017 Thomas Schweich and the GEE Lab at Washington University in St. Louis\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomas-schweich%2FCADPotential","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthomas-schweich%2FCADPotential","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomas-schweich%2FCADPotential/lists"}