Python Forum
Random Particle Simulation in Blender
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Random Particle Simulation in Blender
#4
The problem is that profile2csv was written 10 years ago, only for python 2, so needs a python 3 version
however if compyle is installed for python 3, there is a fix for that.
Make sure you use python 3 for all (i used 3.9.6)

Here's how I tested (see notes at end for fix)

Note all of this done on Linux-mint 20 using python 3.9.6
All steps are included for clarity - please excuse.

  1. Created a test project:
    1. Start a terminal session.
    2. Create directory: mkdir TestCompyle
    3. change dir: cd TestCompyle
    4. create a virtual environment: python -m venv venv
    5. Activate virtual environment: . ./venv/bin/activate
    6. install pycompyle: pip install compyle
    7. Create 'src' directory: mkdir src
    8. add __init__.py to TestCompyle and src directory: touch __init__.py
      touch ./src/__init__.py
  2. add this script to src directory name it SimpleExample.py:
    from compyle.api import Elementwise, annotate, wrap, get_config
    import numpy as np
    
    @annotate
    def axpb(i, x, y, a, b):
        y[i] = a*sin(x[i]) + b
    
    x = np.linspace(0, 1, 10000)
    print(f"x unmodified: {x}")
    y = np.zeros_like(x)
    print(f"y unmodified: {y}")
    
    a, b = 2.0, 3.0
    print(f"a unmodified: {a}, b unmodified: {b}")
    
    backend = 'cython'
    get_config().use_openmp = True
    x, y = wrap(x, y, backend=backend)
    print(f"x after wrap: {x}, y after wrap: {y}")
    e = Elementwise(axpb, backend=backend)
    e(x, y, a, b)
    print(f"e: {e}")
  3. run script: python src/SimpleExample.py
  4. results are:
    Output:
    x unmodified: [0.00000000e+00 1.00010001e-04 2.00020002e-04 ... 9.99799980e-01 9.99899990e-01 1.00000000e+00] y unmodified: [0. 0. 0. ... 0. 0. 0.] a unmodified: 2.0, b unmodified: 3.0 x after wrap: [0.00000000e+00 1.00010001e-04 2.00020002e-04 ... 9.99799980e-01 9.99899990e-01 1.00000000e+00], y after wrap: [0. 0. 0. ... 0. 0. 0.] e: <compyle.parallel.Elementwise object at 0x7f6c9ef85eb0>

I didn't expand e, but didn't need to, the exercise is to make sure all works
So, my guess is that after you install PySPH, reinstall complye and then try your code.

Hope this works for you
Reply


Messages In This Thread
Random Particle Simulation in Blender - by willm168 - Jul-12-2021, 05:13 PM
RE: Random Particle Simulation in Blender - by Larz60+ - Jul-13-2021, 10:54 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020