Closed bmahlbrand closed 2 years ago
I'm not exactly sure what the question is, but the following is an easy way to generate random velocity fields:
from phi.flow import *
CenteredGrid(Noise(vector=2), extrapolation.ZERO, x=32, y=48)
I think you got to the crux of what I was looking for, totally unclear in retrospect :)
Maybe I should add that to sample a batch of velocity fields, you can add a batch dimension like this:
Noise(batch(batch=10), vector=2)
What about seeding the Noise? Maybe I'm looking to generate random inflows of velocity - can you show a simple example of one? Adding randomized ones together is trivial enough, but not sure if there's some shortcuts to deal w/velocity inflows. Like can I create noise spheres to act as emitters on the velocity field?
At the moment, there is no explicit seed control in the Noise
class, but you can set the global seed using math.seed()
.
As for the spherical inflow, how about something like this:
velocity = StaggeredGrid(0, extrapolation.PERIODIC, x=100, y=80)
inflow = (Noise() @ velocity) * (Sphere((50, 40), radius=10) @ velocity)
velocity += inflow * dt
Are all of these operations supported in 3d? Getting TypeError: unsupported operand type(s) for @: 'Noise' and 'StaggeredGrid'
when I do something like: VEL_INFLOW = (Noise(vector=3, scale = vel_inflow_magnitude) @ velocity) * (Sphere(pos, radius=vel_inflow_radius) @ velocity)
Yes, it works in 3D. Try
velocity = StaggeredGrid(0, extrapolation.PERIODIC, x=100, y=80, z=10)
VEL_INFLOW = (Noise(vector=3, scale = 10) @ velocity) * (Sphere((50, 40, 4), radius=10) @ velocity)
Maybe check that you are on version 2.0.0 (no rc) using phi.__version__
Ahhh! I upgraded to 2.0.0 ;) that helped.
Also did you change operators? Is >>
valid anymore? Upgraded and now it's complaining about it. I just changed it to @
and it seems to work.
Yes, it was renamed to @
to match at()
.
Makes sense to me! Thanks.
I see ways to initialize velocity fields with a single shape, but can I generate several simultaneously? I'm looking to replicate some of TempoGAN's dataset with randomly initialized velocities.