POV-Ray : Newsgroups : povray.off-topic : Liquid Physics Server Time
1 Oct 2024 15:22:33 EDT (-0400)
  Liquid Physics (Message 21 to 30 of 37)  
<<< Previous 10 Messages Goto Latest 10 Messages Next 7 Messages >>>
From: Invisible
Subject: Re: Liquid Physics
Date: 1 Apr 2008 04:43:16
Message: <47f203b4@news.povray.org>
scott wrote:

> Yes, inside the "acceleration" function, which is called from each 
> "evaluate" you put your code for calculating the acceleration.  This, in 
> your case, would presumably call the routine to check for collisions and 
> work out the forces for all the particles.
> 
> Note that you need to put all the positions and velocities for every 
> particle inside some state block and evaluate them in parallel using 
> this algorithm - you can't do one at a time it doesn't work like that.

Question: Would it be worth using some kind of space partitioning to 
enable you to process only "nearby" particles?

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

From: scott
Subject: Re: Liquid Physics
Date: 1 Apr 2008 05:13:04
Message: <47f20ab0@news.povray.org>
> Question: Would it be worth using some kind of space partitioning to 
> enable you to process only "nearby" particles?

I think he said he was using something like that already.


Post a reply to this message

From: Invisible
Subject: Re: Liquid Physics
Date: 1 Apr 2008 06:30:22
Message: <47f21cce@news.povray.org>
scott wrote:
>> Question: Would it be worth using some kind of space partitioning to 
>> enable you to process only "nearby" particles?
> 
> I think he said he was using something like that already.

Ah, OK.

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

From: Darren New
Subject: Re: Liquid Physics
Date: 1 Apr 2008 14:54:59
Message: <47f29313@news.povray.org>
Invisible wrote:
> It's like, a function can only have one body. Nobody would find that 
> surprising.

Unless you're using Erlang, I guess. :-)

"This is beyond dynamic binding. This is 
make-up-your-mind-after-it's-already-running binding."

-- 
   Darren New / San Diego, CA, USA (PST)
     "That's pretty. Where's that?"
          "It's the Age of Channelwood."
     "We should go there on vacation some time."


Post a reply to this message

From: Orchid XP v8
Subject: Re: Liquid Physics
Date: 1 Apr 2008 15:04:03
Message: <47f29533$1@news.povray.org>
Chambers wrote:

> BTW, that grasshopper thing... does that come from the old TV show "Kung 
> Fu"?  I could have sworn I saw it in a movie, though.  In fact, I asked 
> at a couple local video stores what movie it was, and nobody knew... :(

I have no idea. My boss used to call me grasshopper. No idea why...


Post a reply to this message

From: Stephen
Subject: Re: Liquid Physics
Date: 1 Apr 2008 15:17:55
Message: <u165v353jn1eekrhb3gdl47qfvu73dudat@4ax.com>
On Tue, 01 Apr 2008 21:04:23 +0100, Orchid XP v8 <voi### [at] devnull>
wrote:

>Chambers wrote:
>
>> BTW, that grasshopper thing... does that come from the old TV show "Kung 
>> Fu"?  I could have sworn I saw it in a movie, though.  In fact, I asked 
>> at a couple local video stores what movie it was, and nobody knew... :(
>
>I have no idea. My boss used to call me grasshopper. No idea why...

Walk the rice paper and leave no mark, Grasshopper.
-- 

Regards
     Stephen


Post a reply to this message

From: Invisible
Subject: Re: Wave Physics
Date: 2 Apr 2008 07:06:01
Message: <47f376a9$1@news.povray.org>
While we're on the subject... I've managed to get particle systems like 
this to work before. (E.g., my chaos pendulum example, and various other 
things.) What I haven't ever managed to do is figure out how to build 
myself my own wave tank.

I know I've asked this before, but what's the algorithm for this?

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

From: Invisible
Subject: Re: Liquid Physics
Date: 2 Apr 2008 07:18:18
Message: <47f3798a@news.povray.org>
Right. Well maybe it would be helpful to fix a few typos...

>   evaluate (v,p) t dt (dv,dp) =
>     let
>       v' = v + dt*dv
>       p' = p + dt*dp
>     in  (v', a (t+dt) v' p')

Err... that's incorrect. The acceleration function ("a") needs to be a 
parameter somewhere. Or it needs to be a top-level function. Let's make 
it top-level, like in the C++ version:

   acceleration t v p = ???

   evaluate (v,p) t dt Nothing = (v, acceleration t)
   evaluate (v,p) t dt (Just (dv,dp)) =
     let
       v' = v + dt*dv
       p' = p + dt*dp
     in  (v', acceleration (t+dt) v' p')

[I made the derivatives optional too. Did I get it right?]

>   integrate t dt a (v,p) =
>     let
>       a = evaluate (v,p) t dt -- er... where's the rest?
>       b = evaluate (v,p) t (dt/2) a
>       c = evaluate (v,p) t (dt/2) b
>       d = evaluate (v,p) t dt     c
>       dv = (fst a + 2 * (fst b + fst c) + fst d) / 6
>       dp = (snd a + 2 * (snd b + snd c) + snd d) / 6
>     in (v + dt*dv, p + dt*dp)

...and if we're using a top-level acceleration function, you don't need 
that "a" parameter there (which incidentally causes a name clash).

   integrate t dt (v,p) =
     let
       a = evaluate (v,p) t dt     Nothing
       b = evaluate (v,p) t (dt/2) (Just a)
       c = evaluate (v,p) t (dt/2) (Just b)
       d = evaluate (v,p) t dt     (Just c)
       dv = (fst a + 2 * (fst b + fst c) + fst d) / 6
       dp = (snd a + 2 * (snd b + snd c) + snd d) / 6
     in  (v + dt*dv, p + dt*dp)

I'll have to try this out later and see if it actually works...

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

From: Invisible
Subject: Re: Physics Code
Date: 2 Apr 2008 07:30:41
Message: <47f37c71$1@news.povray.org>
You know what? Screw it. Let's start again...

data State = State {velocity, position :: !Double}

data Derivative = Derivative {dvelocity, dposition :: !Double}

evaluate :: State -> Double -> Double -> Maybe Derivative -> Derivative
evaluate s t dt Nothing = Derivative {dvelocity = acceleration s t, 
dposition = velocity s}
evaluate s t dt (Just d) =
   let
     s' = State {velocity = velocity s + dvelocity d * dt, position = 
position s + dposition d * dt}
   in  Derivative {dvelocity = acceleration s' (t+dt), dposition = 
velocity s'}

integrate :: State -> Double -> Double -> State
integrate s t dt =
   let
     a = evaluate s t dt     Nothing
     b = evaluate s t (dt/2) (Just a)
     c = evaluate s t (dt/2) (Just b)
     d = evaluate s t dt     (Just c)
     dv = (dvelocity a + 2 * (dvelocity b + dvelocity c) + dvelocity d) / 6
     dp = (dposition a + 2 * (dposition b + dposition c) + dposition d) / 6
   in  State {velocity = velocity s + dv * dt, position = position s + 
dp * dt}

acceleration :: State -> Double -> Double
acceleration = error "not implemented yet"

Does that look correct?

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

From: Invisible
Subject: Re: Physics Code
Date: 2 Apr 2008 07:47:08
Message: <47f3804c$1@news.povray.org>
Invisible wrote:

> Does that look correct?

Well, I just ran it on a simple harmonic oscilator and got a sine wave, 
so that's always a good start...

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

<<< Previous 10 Messages Goto Latest 10 Messages Next 7 Messages >>>

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.