imryk
imryk

Reputation: 1

how do i compile from pyjet import without a compile error?

I'm trying to compile the code from the following tutorial: https://fluidenginedevelopment.org/documentation/python.html

Here is the tutorial code:

from pyjet import *
import sys
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation

ANIM_NUM_FRAMES = 360
ANIM_FPS = 60


def main():
    # Create smoke solver
    resX = 100
    solver = GridSmokeSolver2(resolution=(resX, 2 * resX), domainSizeX=1.0)

    # Customize pressure solver for real-time sim (less accurate, but much faster)
    pressureSolver = GridFractionalSinglePhasePressureSolver2()
    pressureSolver.linearSystemSolver = FdmGaussSeidelSolver2(20, 20, 0.001)
    solver.pressureSolver = pressureSolver

    # Setup emitter
    sphere = Sphere2(center=(0.5, 0.5), radius=0.15)
    emitter = VolumeGridEmitter2(sourceRegion=sphere)
    solver.emitter = emitter
    emitter.addStepFunctionTarget(solver.smokeDensity, 0.0, 1.0)
    emitter.addStepFunctionTarget(solver.temperature, 0.0, 1.0)

    # Visualization
    fig = plt.figure()
    den = np.array(solver.smokeDensity.dataAccessor(), copy=False)
    im = plt.imshow(den, vmin=0, vmax=1, cmap=plt.cm.gray,
                    interpolation='bicubic', animated=True, origin='lower')

    # Animation
    frame = Frame(0, 1.0 / ANIM_FPS)
    def updatefig(*args):
        solver.update(frame)
        frame.advance()
        den = np.array(solver.smokeDensity.dataAccessor(), copy=False)
        im.set_data(den)
        return im,

    if len(sys.argv) > 1:
        format = sys.argv[1]
        if format == 'gif':
            anim = animation.FuncAnimation(fig, updatefig,
                                           frames=ANIM_NUM_FRAMES,
                                           interval=ANIM_FPS, blit=True)
            anim.save('smoke_example01.gif', fps=ANIM_FPS, dpi=72,
                      writer='imagemagick')
        elif format == 'mp4':
            anim = animation.FuncAnimation(fig, updatefig,
                                           frames=ANIM_NUM_FRAMES,
                                           interval=ANIM_FPS, blit=True)
            anim.save('smoke_example01.mp4', fps=ANIM_FPS, writer='ffmpeg')
    else:
        anim = animation.FuncAnimation(fig, updatefig, frames=ANIM_NUM_FRAMES,
                                       interval=1, blit=True)
        plt.show()


if __name__ == '__main__':
    Logging.mute()
    main()

before I'll change it to fit the logo I'm making. I've installed all of the required libraries (in pycharm), and I get the following error while trying to compile it:

/home/kali/PycharmProjects/AndromedaLogo/venv/bin/python /home/kali/PycharmProjects/AndromedaLogo/main.py Traceback (most recent call last): File "/home/kali/PycharmProjects/AndromedaLogo/main.py", line 1, in from pyjet import * TypeError: Item in pyjet.all must be str, not dtype

What seems to be the problem?

Upvotes: 0

Views: 60

Answers (1)

Exelian
Exelian

Reputation: 5888

I think there's an issue with the library you are currently using. The issue is occuring at import time, which is before any of your code is running. The problem seems to be related to some initialization issue.

Specifically the reference the pyjet.all items must be strings instead of dtype makes me assume that for some reason a numpy array is being pass where it should've been a normal list of strings.

TypeError: Item in pyjet.all must be str, not dtype

I would suggest removing the software you installed and making sure you install the correct version (the one for which the tutorial is written).

Upvotes: 0

Related Questions