-
Notifications
You must be signed in to change notification settings - Fork 82
.397395619494580:d47dd55fb18e76a37faa5630df4a183c_69e6210c180bcf8a442e5ffe.69e626c1180bcf8a442e6059.69e626c0966af563bdeec98e:Trae CN.T(2026/4/20 21:14:41) #114
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
Open
yangou-hash
wants to merge
2
commits into
taichi-dev:master
Choose a base branch
from
yangou-hash:ouyu_trae_2
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| import sys | ||
| import os | ||
| project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | ||
| sys.path.insert(0, project_root) | ||
| sys.path.insert(0, os.path.join(project_root, 'local_packages')) | ||
|
|
||
| import taichi as ti | ||
| import numpy as np | ||
| from engine.mpm_solver import MPMSolver | ||
|
|
||
| ti.init(arch=ti.cpu) | ||
|
|
||
| print("=== Testing Wind Field Feature ===") | ||
| print() | ||
|
|
||
| mpm = MPMSolver(res=(32, 32, 32), size=10) | ||
|
|
||
| mpm.add_cube(lower_corner=[1, 4, 4], | ||
| cube_size=[1, 1, 1], | ||
| material=MPMSolver.material_water, | ||
| velocity=[0, 0, 0]) | ||
|
|
||
| mpm.set_gravity((0, -20, 0)) | ||
|
|
||
| mpm.add_wind_field( | ||
| lower_bound=[0, 0, 0], | ||
| upper_bound=[3, 10, 10], | ||
| force=[100, 0, 0] | ||
| ) | ||
|
|
||
| print("Initial particles:") | ||
| particles = mpm.particle_info() | ||
| print(f" Number of particles: {len(particles['position'])}") | ||
| print(f" Initial X positions range: [{particles['position'][:, 0].min():.3f}, {particles['position'][:, 0].max():.3f}]") | ||
| print(f" Initial mean X position: {particles['position'][:, 0].mean():.3f}") | ||
| print() | ||
|
|
||
| print("Running simulation for 100 steps...") | ||
| for frame in range(100): | ||
| mpm.step(4e-3) | ||
| if frame % 20 == 0: | ||
| particles = mpm.particle_info() | ||
| mean_x = particles['position'][:, 0].mean() | ||
| mean_vx = particles['velocity'][:, 0].mean() | ||
| print(f" Step {frame:3d}: mean X = {mean_x:.3f}, mean Vx = {mean_vx:.3f}") | ||
|
|
||
| print() | ||
| print("Final state:") | ||
| particles = mpm.particle_info() | ||
| print(f" Final X positions range: [{particles['position'][:, 0].min():.3f}, {particles['position'][:, 0].max():.3f}]") | ||
| print(f" Final mean X position: {particles['position'][:, 0].mean():.3f}") | ||
| print(f" Final mean X velocity: {particles['velocity'][:, 0].mean():.3f}") | ||
| print() | ||
| print("=== Wind Field Test Passed! ===") | ||
| print("Particles should have moved to the right due to the wind field.") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| #!E:\ProgramFiles\Anaconda\python.exe | ||
| # | ||
| # Author: Mike McKerns (mmckerns @caltech and @uqfoundation) | ||
| # Copyright (c) 2008-2016 California Institute of Technology. | ||
| # Copyright (c) 2016-2026 The Uncertainty Quantification Foundation. | ||
| # License: 3-clause BSD. The full license text is available at: | ||
| # - https://github.com/uqfoundation/dill/blob/master/LICENSE | ||
| ''' | ||
| build profile graph for the given instance | ||
|
|
||
| running: | ||
| $ get_gprof <args> <instance> | ||
|
|
||
| executes: | ||
| gprof2dot -f pstats <args> <type>.prof | dot -Tpng -o <type>.call.png | ||
|
|
||
| where: | ||
| <args> are arguments for gprof2dot, such as "-n 5 -e 5" | ||
| <instance> is code to create the instance to profile | ||
| <type> is the class of the instance (i.e. type(instance)) | ||
|
|
||
| For example: | ||
| $ get_gprof -n 5 -e 1 "import numpy; numpy.array([1,2])" | ||
|
|
||
| will create 'ndarray.call.png' with the profile graph for numpy.array([1,2]), | ||
| where '-n 5' eliminates nodes below 5% threshold, similarly '-e 1' eliminates | ||
| edges below 1% threshold | ||
| ''' | ||
|
|
||
| if __name__ == "__main__": | ||
| import sys | ||
| if len(sys.argv) < 2: | ||
| print ("Please provide an object instance (e.g. 'import math; math.pi')") | ||
| sys.exit() | ||
| # grab args for gprof2dot | ||
| args = sys.argv[1:-1] | ||
| args = ' '.join(args) | ||
| # last arg builds the object | ||
| obj = sys.argv[-1] | ||
| obj = obj.split(';') | ||
| # multi-line prep for generating an instance | ||
| for line in obj[:-1]: | ||
| exec(line) | ||
| # one-line generation of an instance | ||
| try: | ||
| obj = eval(obj[-1]) | ||
| except Exception: | ||
| print ("Error processing object instance") | ||
| sys.exit() | ||
|
|
||
| # get object 'name' | ||
| objtype = type(obj) | ||
| name = getattr(objtype, '__name__', getattr(objtype, '__class__', objtype)) | ||
|
|
||
| # profile dumping an object | ||
| import dill | ||
| import os | ||
| import cProfile | ||
| #name = os.path.splitext(os.path.basename(__file__))[0] | ||
| cProfile.run("dill.dumps(obj)", filename="%s.prof" % name) | ||
| msg = "gprof2dot -f pstats %s %s.prof | dot -Tpng -o %s.call.png" % (args, name, name) | ||
| try: | ||
| res = os.system(msg) | ||
| except Exception: | ||
| print ("Please verify install of 'gprof2dot' to view profile graphs") | ||
| if res: | ||
| print ("Please verify install of 'gprof2dot' to view profile graphs") | ||
|
|
||
| # get stats | ||
| f_prof = "%s.prof" % name | ||
| import pstats | ||
| stats = pstats.Stats(f_prof, stream=sys.stdout) | ||
| stats.strip_dirs().sort_stats('cumtime') | ||
| stats.print_stats(20) #XXX: save to file instead of print top 20? | ||
| os.remove(f_prof) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| #!E:\ProgramFiles\Anaconda\python.exe | ||
| # | ||
| # Author: Mike McKerns (mmckerns @caltech and @uqfoundation) | ||
| # Copyright (c) 2008-2016 California Institute of Technology. | ||
| # Copyright (c) 2016-2026 The Uncertainty Quantification Foundation. | ||
| # License: 3-clause BSD. The full license text is available at: | ||
| # - https://github.com/uqfoundation/dill/blob/master/LICENSE | ||
| """ | ||
| display the reference paths for objects in ``dill.types`` or a .pkl file | ||
|
|
||
| Notes: | ||
| the generated image is useful in showing the pointer references in | ||
| objects that are or can be pickled. Any object in ``dill.objects`` | ||
| listed in ``dill.load_types(picklable=True, unpicklable=True)`` works. | ||
|
|
||
| Examples:: | ||
|
|
||
| $ get_objgraph ArrayType | ||
| Image generated as ArrayType.png | ||
| """ | ||
|
|
||
| import dill as pickle | ||
| #pickle.debug.trace(True) | ||
| #import pickle | ||
|
|
||
| # get all objects for testing | ||
| from dill import load_types | ||
| load_types(pickleable=True,unpickleable=True) | ||
| from dill import objects | ||
|
|
||
| if __name__ == "__main__": | ||
| import sys | ||
| if len(sys.argv) != 2: | ||
| print ("Please provide exactly one file or type name (e.g. 'IntType')") | ||
| msg = "\n" | ||
| for objtype in list(objects.keys())[:40]: | ||
| msg += objtype + ', ' | ||
| print (msg + "...") | ||
| else: | ||
| objtype = str(sys.argv[-1]) | ||
| try: | ||
| obj = objects[objtype] | ||
| except KeyError: | ||
| obj = pickle.load(open(objtype,'rb')) | ||
| import os | ||
| objtype = os.path.splitext(objtype)[0] | ||
| try: | ||
| import objgraph | ||
| objgraph.show_refs(obj, filename=objtype+'.png') | ||
| except ImportError: | ||
| print ("Please install 'objgraph' to view object graphs") | ||
|
|
||
|
|
||
| # EOF |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| #!E:\ProgramFiles\Anaconda\python.exe | ||
| # | ||
| # Author: Mike McKerns (mmckerns @caltech and @uqfoundation) | ||
| # Copyright (c) 2008-2016 California Institute of Technology. | ||
| # Copyright (c) 2016-2026 The Uncertainty Quantification Foundation. | ||
| # License: 3-clause BSD. The full license text is available at: | ||
| # - https://github.com/uqfoundation/dill/blob/master/LICENSE | ||
| """ | ||
| unpickle the contents of a pickled object file | ||
|
|
||
| Examples:: | ||
|
|
||
| $ undill hello.pkl | ||
| ['hello', 'world'] | ||
| """ | ||
|
|
||
| if __name__ == '__main__': | ||
| import sys | ||
| import dill | ||
| for file in sys.argv[1:]: | ||
| print (dill.load(open(file,'rb'))) | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| pip |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back 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.
Demo switched from GPU to CPU for testing
Medium Severity
The
ti.initcall was changed fromti.cudawithdevice_memory_GB=4.0toti.cpu, and the comment explicitly says "for testing." A 3D MPM simulation running 1500 frames on CPU will be orders of magnitude slower than on GPU, making this demo effectively unusable for its intended purpose.Reviewed by Cursor Bugbot for commit cc2c936. Configure here.