### Author Topic: *v^2 in a physlets formula for air resistance  (Read 13545 times)

#### ahmedelshfie

• Hero Member
• Posts: 930
##### *v^2 in a physlets formula for air resistance
« on: June 10, 2010, 08:52:17 pm »
Hi prof Hwang
I modified project *v^2 in a physlets formula for air resistance and come to my mind idea to add slider for control in angle(theta)
So i add slider position up name is theta and back to equation and typing it
vx=V*Math.cos(angle/90);
vy=V*Math.sin(angle/90);
After i back again to slider theta and add the following values in image gif that I'm attach
But I'm sure have wrong because when i drag slider theta to value less 40 simulation not work
I don't know why
Could you check prof what wrong i make
Thanks
I attach also jar,,XML files of simulation
« Last Edit: June 10, 2010, 08:54:06 pm by ahmedelshfie »

#### Fu-Kwun Hwang

• Hero Member
• Posts: 3062
##### Re: *v^2 in a physlets formula for air resistance
« Reply #1 on: June 10, 2010, 11:31:33 pm »
For angle in degree from 0 to 180 is correspond cta in radian from 0 to pi.
so cta= angle*pi/180.;

where pi=3.14159 or you can define variable pi=Math.PI;// where Math.PI is a pre-defined java constant

i.e. You should use vx=V*Math.cos(angle*pi/180.);

or define a2c=pi/180.; //  angle in degree to cta in radian
and use vx=V*Math.cos(angle*a2c);

#### ahmedelshfie

• Hero Member
• Posts: 930
##### Re: *v^2 in a physlets formula for air resistance
« Reply #2 on: June 11, 2010, 01:04:16 am »
I do first solution that is i use variable pi=3.14159 in page basic.
And equation:
vx=V*Math.cos(angle*pi/180.);
But i notice that arrow of velocity is down by way strange down more than normally,,cant drag arrow easy for degree i want,,movement of mass slowly.
And if i use less value on slider theta simulation no work.
I don't know what wrong i do.
And i want say another point when i change value of pi from 3.14159 to Math.PI happend diffrent movement i can say is more good than i use pi=3.14159.
But problems about velocity arrow,,hard control in drag slider of theta and when less value on slider theta simulation no work is the same no change may is have some diffrent in movement become more fast.
I upload applet for you check prof by first value pi=3.14159.
Applet prof

Full screen applet or Problem viewing java?Add http://www.phy.ntnu.edu.tw/ to exception site list
• Please feel free to post your ideas about how to use the simulation for better teaching and learning.
• Post questions to be asked to help students to think, to explore.
• Upload worksheets as attached files to share with more users.
Let's work together. We can help more users understand physics conceptually and enjoy the fun of learning physics!

« Last Edit: June 11, 2010, 02:09:58 am by ahmedelshfie »

#### Fu-Kwun Hwang

• Hero Member
• Posts: 3062
##### Re: *v^2 in a physlets formula for air resistance
« Reply #3 on: June 11, 2010, 06:01:10 pm »
The problem is due to code in "Fixed relation" page.
if(_isPlaying() && x>xmin+size && y_initialize();
playpause();
}

And the following code in the "initialize" page.
vx=V*Math.cos(angle/90);
vy=V*Math.sin(angle/90);
x=xmin+size2;
y=ymin+size2;
t=0.;
When you click "Play" x>xmin and ySo it execute initialize page again.

You can fix it if you modify the code in "Fixed relation" page to.
if(_isPlaying() && x>[b]xmax[/b]+size && y_initialize();
playpause();
}
and the code in initialize page to
vx=V*Math.cos(angle*Math.PI/180);
vy=V*Math.sin(angle*Math.PI/180);
x=xmin+size2;
y=ymin+size2;
t=0.;

#### ahmedelshfie

• Hero Member
• Posts: 930
##### Re: *v^2 in a physlets formula for air resistance
« Reply #4 on: June 11, 2010, 07:17:14 pm »
I solve problem about control in arrow of velocity and work now very well.
But code in "Fixed relation" page.
if(_isPlaying() && x>xmin+size && y<ymin+size ){
_initialize();
playpause();
}
BY the way is the original code that i find when i begin modified simulation
And code in the "initialize" page.
vx=V*Math.cos(angle*PI/180.);
vy=V*Math.sin(angle*PI/180);
x=xmin+size2;
y=ymin+size2;
t=0.;
Second code i modified but first code is original I'm no change
And i modified variable pi=3.14159 to PI=3.14159
When i use code you post prof ejs consul give 7 error so i back to Original code
And post for you check what wrong i made more.
About a nother problems is the same (velocity is slowly),,,when i drag slider to value less than 30 degree simulation no work.
Applet after solve problem arrow of velocity

Full screen applet or Problem viewing java?Add http://www.phy.ntnu.edu.tw/ to exception site list
• Please feel free to post your ideas about how to use the simulation for better teaching and learning.
• Post questions to be asked to help students to think, to explore.
• Upload worksheets as attached files to share with more users.
Let's work together. We can help more users understand physics conceptually and enjoy the fun of learning physics!

« Last Edit: June 11, 2010, 07:31:06 pm by ahmedelshfie »

#### Fu-Kwun Hwang

• Hero Member
• Posts: 3062
##### Re: *v^2 in a physlets formula for air resistance
« Reply #5 on: June 12, 2010, 11:20:09 pm »
it was a bug in my original code, and it is fixed now.

#### ahmedelshfie

• Hero Member
• Posts: 930
##### Re: *v^2 in a physlets formula for air resistance
« Reply #6 on: June 13, 2010, 01:28:57 am »
Yes prof
But I'm try solve problem about when i drag theta less than 30 degree
Simulation not work i don't know where is wrong  can you fix this wrong prof please
Thanks

#### Fu-Kwun Hwang

• Hero Member
• Posts: 3062
##### Re: *v^2 in a physlets formula for air resistance
« Reply #7 on: June 13, 2010, 10:08:48 am »
Please upload latest ejs xml source so that I can check it out.

#### ahmedelshfie

• Hero Member
• Posts: 930
##### Re: *v^2 in a physlets formula for air resistance
« Reply #8 on: June 13, 2010, 12:01:04 pm »
Here is source code about last version of airdrag

#### ahmedelshfie

• Hero Member
• Posts: 930
##### Re: *v^2 in a physlets formula for air resistance
« Reply #9 on: June 14, 2010, 09:58:21 pm »
And second applet prof is last version so i upload XML source code and have the jar file in second applet

#### Fu-Kwun Hwang

• Hero Member
• Posts: 3062
##### Re: *v^2 in a physlets formula for air resistance
« Reply #10 on: June 14, 2010, 10:28:31 pm »
Initialize page:
vy=V*Math.sin(angle);
need to be modified to
vy=V*Math.sin(angle[color=red]*pi/180.[/color]);

code in "fixed relation" page
if(_isPlaying() && x>xmin+size && y<ymin+size )
need to be modified to
if(_isPlaying() && x>xm[color=red]a[/color]x+size && y<ymin+size )

Then, it should be fine (or check out attached file).

#### ahmedelshfie

• Hero Member
• Posts: 930
##### Re: *v^2 in a physlets formula for air resistance
« Reply #11 on: June 15, 2010, 12:09:54 am »
Now work very well thank you prof you the best
Last ask what is job of K1 and k2
« Last Edit: June 15, 2010, 12:11:47 am by ahmedelshfie »

#### Fu-Kwun Hwang

• Hero Member
• Posts: 3062
##### Re: *v^2 in a physlets formula for air resistance
« Reply #12 on: June 15, 2010, 12:20:18 am »
The above simulation assume air drag is model with \$F=k1*V+k2*V^2\$ where \$V\$ is the magnitude of the velocity.

Nomally, for high speed projectile, the force is proportional to velocity square. i.e.\$ k1=0, k2>0\$
Howeve,for slow projectile, the force is proportional to velocity. i.e.\$ k1>0, k2=0\$
e.g. simulate a projectile moving under water.

User can adjust \$k1,k2\$ to find a suitable model for the case s/he want to simulated and compared with the real case under studied.
And that can be one of the purpose for the above simulation. To find out a suitbale model for a real case.

#### ahmedelshfie

• Hero Member
• Posts: 930
##### Re: *v^2 in a physlets formula for air resistance
« Reply #13 on: June 15, 2010, 01:19:15 am »
Very well prof thanks for information's.but i notice a thing prof in applet when theta = 0.0 mass move to down
I mean even i don't drag slider theta and I'm just press play without drag theta simulation work but what is strange
Is mass work and fall to down
My ask how theta 0.0 and mass fall down i think mass should be move direct or not move but
Is moving down i will upload applet for you check prof

Full screen applet or Problem viewing java?Add http://www.phy.ntnu.edu.tw/ to exception site list
• Please feel free to post your ideas about how to use the simulation for better teaching and learning.
• Post questions to be asked to help students to think, to explore.
• Upload worksheets as attached files to share with more users.
Let's work together. We can help more users understand physics conceptually and enjoy the fun of learning physics!
« Last Edit: June 15, 2010, 02:14:33 am by ahmedelshfie »