NTNUJAVA Virtual Physics Laboratory
Enjoy the fun of physics with simulations!
Backup site http://enjoy.phy.ntnu.edu.tw/ntnujava/
October 19, 2017, 04:13:55 pm *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
"Life is the beaty of art, heart, and humanity."...Wisdom
Google Bookmarks Yahoo My Web MSN Live Netscape Del.icio.us FURL Stumble Upon Delirious Ask FaceBook

Pages: [1]   Go Down
  Print  
Author Topic: how to make a differentiation of a string?  (Read 7759 times)
0 Members and 1 Guest are viewing this topic. Click to toggle author information(expand message area).
lookang
Hero Member
*****
Offline Offline

Posts: 1784


http://weelookang.blogspot.com


WWW
«
Embed this message
on: January 29, 2009, 04:24:36 pm » posted from:Singapore,,Singapore

I have an interface function field called fstring.

it read the string value in it and is pass to the graphics view as an analyticCurve with
X() = x
Y() = %fstring%

i am able to draw a nice graph say sin(x-t). perfect!


but how do i make a d(sin(x-t)/dt ?

i tried putting an evolution page

d(fstring)/dt = velocity

and make another analyticCurve

X() = x
Y() = velocity

doesn't seem to work, any idea how to make graph of d(fstring)/dt.

thanks!

if you want to see my xml, just delete the evolution page and it will run Grin


* sfstring.PNG (47.59 KB, 1024x768 - viewed 317 times.)

*** There are 1 more attached files. You need to login to acces it!
« Last Edit: January 29, 2009, 09:23:42 pm by lookang » Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3080



WWW
«
Embed this message
Reply #1 on: January 29, 2009, 06:09:28 pm »

You can use AnalyticCurve to draw curve directly.
Since you used
Code:
double u = _view.waveFunction.evaluate(x,t);
to evaluate it's value in your code.

You can calculate u2=_view.waveFunction.evaluate(x,t-ddt);
And you can get du/dt with u2-u/ddt if ddt is small enough!
Just calculated it by definition!
Logged
lookang
Hero Member
*****
Offline Offline

Posts: 1784


http://weelookang.blogspot.com


WWW
«
Embed this message
Reply #2 on: January 29, 2009, 09:23:05 pm » posted from:Singapore,,Singapore

You can use AnalyticCurve to draw curve directly.
Since you used
Code:
double u = _view.waveFunction.evaluate(x,t);
to evaluate it's value in your code.

You can calculate u2=_view.waveFunction.evaluate(x,t-ddt);
And you can get du/dt with (u2-u)/ddt if ddt is small enough!
Just calculated it by definition!


it was a brilliant idea/method but it didn't solve the problem Sad It is because the code above is for the n = 50 points that is spread out in the x-axis, the little points.


original code from paco and wolfgang seems to use the %string% method to draw the nice function.
guess it is difficult to get du/dx =  k*cos ( k*x - w*t) from a string u = sin ( k*x - w*t).

i go try your idea but on a separate loop.

« Last Edit: January 29, 2009, 09:58:43 pm by lookang » Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3080



WWW
«
Embed this message
Reply #3 on: January 29, 2009, 09:29:18 pm »

You are differential it in time, so it should not matter if your points are spread out in space.
I do not understand why you said it is not working. May be you have another problem.

And becareful: It is not correct to write something like sin(x-t)
x and t is not the same dimension. You can not substract time from space

You can write sin(k*x-w*t). But sin(x-t) is meanless.
Logged
lookang
Hero Member
*****
Offline Offline

Posts: 1784


http://weelookang.blogspot.com


WWW
«
Embed this message
Reply #4 on: January 29, 2009, 09:54:58 pm » posted from:Singapore,,Singapore

You are differential it in time, so it should not matter if your points are spread out in space.
I do not understand why you said it is not working. May be you have another problem.

And becareful: It is not correct to write something like sin(x-t)
x and t is not the same dimension. You can not substract time from space

You can write sin(k*x-w*t). But sin(x-t) is meanless.


LOL agreed, sin(k*x-w*t), i was assuming k =1 and w =1 for quick typing Smiley

i now get strange simulation, think i debug tomorrow

found one bug!!
dudt = (u2-u)/ddt; // () is so important Smiley

let me give it some time to crack it before i ask u again Smiley

think i need
du/dx =  k*cos ( k*x - w*t) from a string u = sin ( k*x - w*t) instead of du/dt


*** There are 1 more attached files. You need to login to acces it!
« Last Edit: January 29, 2009, 09:59:33 pm by lookang » Logged
lookang
Hero Member
*****
Offline Offline

Posts: 1784


http://weelookang.blogspot.com


WWW
«
Embed this message
Reply #5 on: January 30, 2009, 02:29:12 am » posted from:Singapore,,Singapore

it works now, need to refine it. thanks!


*** There are 1 more attached files. You need to login to acces it!
Logged
Pages: [1]   Go Up
  Print  
"Life is the beaty of art, heart, and humanity."...Wisdom
 
Jump to:  


Related Topics
Subject Started by Replies Views Last post
is it possible to make applet make a sound when i condition is met?
Questions related to EJS
lookang 8 10178 Last post December 22, 2008, 12:10:01 pm
by lookang
TRANSVERSE WAVE ON A STRING
Wave
deepika.physicslover 4 12193 Last post October 26, 2009, 04:19:38 pm
by crestiksa
Polynomial y=f(x)=a*x^3+b*x^2+c*x+d (differentiation and intergration)
misc
Fu-Kwun Hwang 0 7074 Last post April 03, 2009, 06:48:33 pm
by Fu-Kwun Hwang
Polynomial y=f(x)=a*x^3+b*x^2+c*x+d (differentiation and intergration)
misc
ahmedelshfie 0 2397 Last post May 20, 2010, 11:50:13 pm
by ahmedelshfie
Use particlesets to simulate wave motion of a string
Examples for beginner who want to learn EJS
Fu-Kwun Hwang 0 3675 Last post June 13, 2010, 10:21:55 am
by Fu-Kwun Hwang
Powered by MySQL Powered by PHP Powered by SMF 1.1.13 | SMF © 2006-2011, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 0.064 seconds with 23 queries.since 2011/06/15