Back to Basic

Moderator: Mike Everman

Post Reply
WebPilot
Posts: 3716
Joined: Tue Dec 07, 2004 6:51 pm
Antipspambot question: 0
Location: 41d 1' N 80d 22' W

Re: Back to Basic

Post by WebPilot » Sun Feb 14, 2010 9:02 pm

  • 500 lbf thrustor
  • 1500 lbm vehicle -> 1 lbm "weighs" 1 lbf
  • f_friction=29.6 lbf
Image (c.t.)
Image

WebPilot
Posts: 3716
Joined: Tue Dec 07, 2004 6:51 pm
Antipspambot question: 0
Location: 41d 1' N 80d 22' W

Re: Back to Basic

Post by WebPilot » Mon Feb 15, 2010 1:22 am

 The error I found previously was due to a "units" problem.

 So, in about 4 minutes time, the vehicle is no longer accelerating and the drag force is 470 lbf, which is 30 lbf "shy" of 500 lbf.
Image

WebPilot
Posts: 3716
Joined: Tue Dec 07, 2004 6:51 pm
Antipspambot question: 0
Location: 41d 1' N 80d 22' W

Re: Back to Basic

Post by WebPilot » Mon Feb 15, 2010 8:56 am

  • 500 lbf thrustor
  • 1500 lbm vehicle -> 1 lbm "weighs" 1 lbf
  • f_friction=29.6 lbf
Image (c.t.)
Distance and velocity vs. time
Image

WebPilot
Posts: 3716
Joined: Tue Dec 07, 2004 6:51 pm
Antipspambot question: 0
Location: 41d 1' N 80d 22' W

Re: Back to Basic

Post by WebPilot » Mon Feb 15, 2010 5:49 pm

 From this, at time = 4 min the distance traveled has been 28 miles and the speed has reached its plateau of 570 mi/hr.

 This simulation has been done using the Euler method which is not the most accurate unless you use a really small time step. I need to compare these answers with those predicted by another method, perhaps fourth-order Runge-Kutta.
Image

WebPilot
Posts: 3716
Joined: Tue Dec 07, 2004 6:51 pm
Antipspambot question: 0
Location: 41d 1' N 80d 22' W

Re: Back to Basic

Post by WebPilot » Mon Feb 15, 2010 11:38 pm

 May do this on a spreadsheet first.
Image

WebPilot
Posts: 3716
Joined: Tue Dec 07, 2004 6:51 pm
Antipspambot question: 0
Location: 41d 1' N 80d 22' W

Re: Back to Basic

Post by WebPilot » Tue Feb 16, 2010 5:50 am

 See an error in this piece of code?

Code: Select all

REM  *****  BASIC  *****
REM computes the 1st derivative as a function of x and u(x)
Function uprime(x,y)
uprime=(x-y)/sqrt(1+x^2)
End Function
Image

PyroJoe
Posts: 1743
Joined: Wed Aug 29, 2007 5:44 pm
Antipspambot question: 125
Location: Texas

Re: Back to Basic

Post by PyroJoe » Tue Feb 16, 2010 2:48 pm

Hmmm, the first thing that jumps out is "sqrt", both programs I have use SQR.
Admittedly, a little lost in the maths, not sure what context we are seeing y here(is it coordinate?). Whats up with (x-y)? Most equations I see SQR(x^2+y^2) instead of SQR(1+x^2).

Well, there are my two shots in the dark. Can I buy a vowel?
Joe

WebPilot
Posts: 3716
Joined: Tue Dec 07, 2004 6:51 pm
Antipspambot question: 0
Location: 41d 1' N 80d 22' W

Re: Back to Basic

Post by WebPilot » Tue Feb 16, 2010 5:27 pm

 Nice try.

 It turns out, sqrt is a legitimate function to use in OpenOffice.org's spreadsheet, but is non-existent for use in a macro. It took me almost 3 hrs to figure that out. I found the error/solution nowheres on the I'net.

 The BASIC they use for macro programming is Sun's StarOffice BASIC. See StarOffice 7 Office Suite - Basic Programmer's Guide, English, in particular pg. 38.
Mathematical Operators
Mathematical operators can be applied to all numbers types, whereas the +
operator can also be used to link strings.
  • + Addition of numbers and date values, linking of strings
  • - Subtraction of numbers and date values
  • * Multiplication of numbers
  • / Division of numbers
  • \ Division of numbers with a whole number result (rounded)
  • ^ Raising the power of numbers
  • MOD module operation (calculation of the rest of a division)
 So, in my case, I had to substitute ^(0.5) for sqrt in my MACRO and everything started to run as planned.
Image

WebPilot
Posts: 3716
Joined: Tue Dec 07, 2004 6:51 pm
Antipspambot question: 0
Location: 41d 1' N 80d 22' W

Re: Back to Basic

Post by WebPilot » Wed Feb 17, 2010 1:39 am

 I've managed to convert a Lotus spreadsheet implementation of RK4 for a 1st order differential equation into ooo which is pretty much an Excel clone. It works with one active MACRO.

Image (c.t.)
Image

WebPilot
Posts: 3716
Joined: Tue Dec 07, 2004 6:51 pm
Antipspambot question: 0
Location: 41d 1' N 80d 22' W

Re: Back to Basic

Post by WebPilot » Wed Feb 17, 2010 6:14 am

 This is the problem that the programming of the spreadsheet solves:

An Initial Value Ordinary Differential Equation Consider the following first-order ordinary differential equation:

 (1+x²)^(½) · du(x)/dx + u(x) = x,   x>0

  u(0) = 0

This is an initial value problem because the boundary condition is known at only one location.
Image

PyroJoe
Posts: 1743
Joined: Wed Aug 29, 2007 5:44 pm
Antipspambot question: 125
Location: Texas

Re: Back to Basic

Post by PyroJoe » Wed Feb 17, 2010 5:45 pm

Hi Forrest,
I am still tinkering, to get a feel for non-uniform acceleration. Here is my latest set of code, far different from the first. Probably still has errors and not accurate, but at least the mph has arced over, and the acceleration is arcing down to zero. I put a limit of .005 on the acceleration (line 210), so the thing wouldn't keep looping as acceleration tapers off towards zero.

The direction your going looks like a highly accurate path.

Code: Select all

10  CLS
20  INPUT "Drag Coefficient Cd 0-1 "; Cd
30  INPUT "Frontal Area of vehicle in sq. feet "; Frontarea
40  INPUT "Rolling Resistance pounds "; RR
50  INPUT "Total Weight in pounds "; weight
60  INPUT "Thrust of engine in pounds "; thrust
70  LET slugweight = weight / 32.174
100 LET termvel=SQR((thrust-RR)/(1/391 * Cd * Frontarea))
110 PRINT "Terminal Velocity=";termvel
120 LET time=0
130 PRINT "time --zero-- print"
140 PRINT "s:"; time; "  mph="; mph; " Drag+RR=";dragforce; " accel=";altaccel;" Force=";sumforces;" miles=";miles
150 PRINT " "
160 LET time = 1
170 LET sumforces=thrust-RR

180 REM-----"LOOP starts below here"------

200 LET altaccel= sumforces/slugweight
210 IF altaccel<0.005 then goto 400
220 'note that accumvelocity=altaccel*1 second)+prevvelocity
230 LET accumvelocity=(altaccel*1)+prevvelocity
240 LET mph = accumvelocity * .681818
250 LET accumfeet =(accumvelocity*1)/2+prevfeet
260 LET miles = accumfeet / 5280
270 LET dragforce =(Cd * (1/391*mph^2)*Frontarea)+RR
280 LET prevvelocity=accumvelocity
290 LET prevfeet=accumfeet
300 LET sumforces=thrust-dragforce
310 PRINT "s:"; time; "  mph="; mph; " Drag+RR=";dragforce; " accel=";altaccel;" Force=";sumforces;" miles=";miles
'(for Qbasic)320 SLEEP (seconds0)
330 LET time = time + 1
340 GOTO 200
400 END
graphs.JPG
1500lbs. 29lbsRR 4.5869s.f. Cd.12 @ 100lbs.Thrust
Last edited by PyroJoe on Thu Feb 18, 2010 2:56 pm, edited 1 time in total.

WebPilot
Posts: 3716
Joined: Tue Dec 07, 2004 6:51 pm
Antipspambot question: 0
Location: 41d 1' N 80d 22' W

Re: Back to Basic

Post by WebPilot » Thu Feb 18, 2010 8:04 am

The direction your going looks like a highly accurate path.
 If I can get two different methods to come up with the same numbers ... I'll stop.

 Latest output (900 secs) from my spreadsheet calc for a 100 lbf'er propelling a 1500 lbm vehicle. Simple Euler method used.

Code: Select all

# Euler Method
#            disp         vel             accel
# time      x i+1         y i+1         dy/dt i+1
# (sec)      (ft)        (ft/sec)      (ft/sec²)
			
0.00E+000	0.000E+000	0.000E+000	1.511E+000
5.00E+000	1.889E+001	7.556E+000	1.510E+000
1.00E+001	7.555E+001	1.511E+001	1.508E+000
1.50E+001	1.699E+002	2.265E+001	1.504E+000
2.00E+001	3.020E+002	3.017E+001	1.498E+000
2.50E+001	4.715E+002	3.765E+001	1.490E+000
3.00E+001	6.784E+002	4.511E+001	1.481E+000
3.50E+001	9.225E+002	5.251E+001	1.470E+000
4.00E+001	1.203E+003	5.986E+001	1.458E+000
4.50E+001	1.521E+003	6.715E+001	1.444E+000
5.00E+001	1.875E+003	7.437E+001	1.429E+000
5.50E+001	2.264E+003	8.152E+001	1.412E+000
6.00E+001	2.690E+003	8.858E+001	1.395E+000
6.50E+001	3.150E+003	9.555E+001	1.375E+000
7.00E+001	3.645E+003	1.024E+002	1.355E+000
7.50E+001	4.174E+003	1.092E+002	1.334E+000
8.00E+001	4.737E+003	1.159E+002	1.312E+000
8.50E+001	5.333E+003	1.224E+002	1.288E+000
9.00E+001	5.961E+003	1.289E+002	1.264E+000
9.50E+001	6.621E+003	1.352E+002	1.239E+000
1.00E+002	7.312E+003	1.414E+002	1.214E+000
1.05E+002	8.035E+003	1.475E+002	1.188E+000
1.10E+002	8.787E+003	1.534E+002	1.161E+000
1.15E+002	9.568E+003	1.592E+002	1.134E+000
1.20E+002	1.038E+004	1.649E+002	1.107E+000
1.25E+002	1.122E+004	1.704E+002	1.079E+000
1.30E+002	1.208E+004	1.758E+002	1.052E+000
1.35E+002	1.297E+004	1.811E+002	1.024E+000
1.40E+002	1.389E+004	1.862E+002	9.958E-001
1.45E+002	1.484E+004	1.912E+002	9.678E-001
1.50E+002	1.580E+004	1.960E+002	9.400E-001
1.55E+002	1.680E+004	2.007E+002	9.122E-001
1.60E+002	1.781E+004	2.053E+002	8.847E-001
1.65E+002	1.885E+004	2.097E+002	8.574E-001
1.70E+002	1.991E+004	2.140E+002	8.304E-001
1.75E+002	2.099E+004	2.181E+002	8.037E-001
1.80E+002	2.209E+004	2.222E+002	7.774E-001
1.85E+002	2.321E+004	2.260E+002	7.515E-001
1.90E+002	2.435E+004	2.298E+002	7.260E-001
1.95E+002	2.551E+004	2.334E+002	7.010E-001
2.00E+002	2.668E+004	2.369E+002	6.765E-001
2.05E+002	2.788E+004	2.403E+002	6.525E-001
2.10E+002	2.909E+004	2.436E+002	6.290E-001
2.15E+002	3.031E+004	2.467E+002	6.061E-001
2.20E+002	3.155E+004	2.498E+002	5.837E-001
2.25E+002	3.281E+004	2.527E+002	5.619E-001
2.30E+002	3.408E+004	2.555E+002	5.407E-001
2.35E+002	3.536E+004	2.582E+002	5.200E-001
2.40E+002	3.666E+004	2.608E+002	5.000E-001
2.45E+002	3.797E+004	2.633E+002	4.805E-001
2.50E+002	3.929E+004	2.657E+002	4.616E-001
2.55E+002	4.063E+004	2.680E+002	4.433E-001
2.60E+002	4.197E+004	2.702E+002	4.255E-001
2.65E+002	4.333E+004	2.723E+002	4.084E-001
2.70E+002	4.470E+004	2.744E+002	3.918E-001
2.75E+002	4.607E+004	2.763E+002	3.757E-001
2.80E+002	4.746E+004	2.782E+002	3.602E-001
2.85E+002	4.885E+004	2.800E+002	3.453E-001
2.90E+002	5.026E+004	2.817E+002	3.309E-001
2.95E+002	5.167E+004	2.834E+002	3.170E-001
3.00E+002	5.309E+004	2.850E+002	3.036E-001
3.05E+002	5.452E+004	2.865E+002	2.907E-001
3.10E+002	5.596E+004	2.880E+002	2.783E-001
3.15E+002	5.740E+004	2.893E+002	2.663E-001
3.20E+002	5.885E+004	2.907E+002	2.548E-001
3.25E+002	6.031E+004	2.920E+002	2.438E-001
3.30E+002	6.177E+004	2.932E+002	2.332E-001
3.35E+002	6.324E+004	2.943E+002	2.230E-001
3.40E+002	6.471E+004	2.955E+002	2.132E-001
3.45E+002	6.619E+004	2.965E+002	2.038E-001
3.50E+002	6.768E+004	2.975E+002	1.948E-001
3.55E+002	6.917E+004	2.985E+002	1.862E-001
3.60E+002	7.066E+004	2.994E+002	1.779E-001
3.65E+002	7.216E+004	3.003E+002	1.700E-001
3.70E+002	7.367E+004	3.012E+002	1.624E-001
3.75E+002	7.517E+004	3.020E+002	1.551E-001
3.80E+002	7.669E+004	3.028E+002	1.481E-001
3.85E+002	7.820E+004	3.035E+002	1.415E-001
3.90E+002	7.972E+004	3.042E+002	1.351E-001
3.95E+002	8.124E+004	3.049E+002	1.289E-001
4.00E+002	8.277E+004	3.055E+002	1.231E-001
4.05E+002	8.430E+004	3.062E+002	1.175E-001
4.10E+002	8.583E+004	3.067E+002	1.121E-001
4.15E+002	8.737E+004	3.073E+002	1.070E-001
4.20E+002	8.890E+004	3.078E+002	1.021E-001
4.25E+002	9.045E+004	3.083E+002	9.745E-002
4.30E+002	9.199E+004	3.088E+002	9.297E-002
4.35E+002	9.353E+004	3.093E+002	8.870E-002
4.40E+002	9.508E+004	3.097E+002	8.462E-002
4.45E+002	9.663E+004	3.102E+002	8.072E-002
4.50E+002	9.818E+004	3.106E+002	7.699E-002
4.55E+002	9.974E+004	3.110E+002	7.344E-002
4.60E+002	1.013E+005	3.113E+002	7.004E-002
4.65E+002	1.028E+005	3.117E+002	6.679E-002
4.70E+002	1.044E+005	3.120E+002	6.370E-002
4.75E+002	1.060E+005	3.123E+002	6.074E-002
4.80E+002	1.075E+005	3.126E+002	5.792E-002
4.85E+002	1.091E+005	3.129E+002	5.522E-002
4.90E+002	1.107E+005	3.132E+002	5.265E-002
4.95E+002	1.122E+005	3.135E+002	5.020E-002
5.00E+002	1.138E+005	3.137E+002	4.786E-002
5.05E+002	1.154E+005	3.139E+002	4.563E-002
5.10E+002	1.169E+005	3.142E+002	4.350E-002
5.15E+002	1.185E+005	3.144E+002	4.146E-002
5.20E+002	1.201E+005	3.146E+002	3.952E-002
5.25E+002	1.217E+005	3.148E+002	3.767E-002
5.30E+002	1.232E+005	3.150E+002	3.591E-002
5.35E+002	1.248E+005	3.152E+002	3.423E-002
5.40E+002	1.264E+005	3.153E+002	3.262E-002
5.45E+002	1.280E+005	3.155E+002	3.109E-002
5.50E+002	1.295E+005	3.157E+002	2.963E-002
5.55E+002	1.311E+005	3.158E+002	2.824E-002
5.60E+002	1.327E+005	3.159E+002	2.692E-002
5.65E+002	1.343E+005	3.161E+002	2.565E-002
5.70E+002	1.359E+005	3.162E+002	2.445E-002
5.75E+002	1.374E+005	3.163E+002	2.330E-002
5.80E+002	1.390E+005	3.164E+002	2.220E-002
5.85E+002	1.406E+005	3.166E+002	2.115E-002
5.90E+002	1.422E+005	3.167E+002	2.016E-002
5.95E+002	1.438E+005	3.168E+002	1.921E-002
6.00E+002	1.453E+005	3.169E+002	1.830E-002
6.05E+002	1.469E+005	3.170E+002	1.744E-002
6.10E+002	1.485E+005	3.170E+002	1.662E-002
6.15E+002	1.501E+005	3.171E+002	1.584E-002
6.20E+002	1.517E+005	3.172E+002	1.509E-002
6.25E+002	1.533E+005	3.173E+002	1.438E-002
6.30E+002	1.549E+005	3.173E+002	1.370E-002
6.35E+002	1.564E+005	3.174E+002	1.305E-002
6.40E+002	1.580E+005	3.175E+002	1.244E-002
6.45E+002	1.596E+005	3.175E+002	1.185E-002
6.50E+002	1.612E+005	3.176E+002	1.129E-002
6.55E+002	1.628E+005	3.177E+002	1.076E-002
6.60E+002	1.644E+005	3.177E+002	1.025E-002
6.65E+002	1.660E+005	3.178E+002	9.764E-003
6.70E+002	1.676E+005	3.178E+002	9.303E-003
6.75E+002	1.692E+005	3.179E+002	8.863E-003
6.80E+002	1.707E+005	3.179E+002	8.444E-003
6.85E+002	1.723E+005	3.179E+002	8.045E-003
6.90E+002	1.739E+005	3.180E+002	7.664E-003
6.95E+002	1.755E+005	3.180E+002	7.302E-003
7.00E+002	1.771E+005	3.181E+002	6.957E-003
7.05E+002	1.787E+005	3.181E+002	6.628E-003
7.10E+002	1.803E+005	3.181E+002	6.314E-003
7.15E+002	1.819E+005	3.182E+002	6.015E-003
7.20E+002	1.835E+005	3.182E+002	5.731E-003
7.25E+002	1.851E+005	3.182E+002	5.460E-003
7.30E+002	1.866E+005	3.182E+002	5.201E-003
7.35E+002	1.882E+005	3.183E+002	4.955E-003
7.40E+002	1.898E+005	3.183E+002	4.721E-003
7.45E+002	1.914E+005	3.183E+002	4.497E-003
7.50E+002	1.930E+005	3.183E+002	4.284E-003
7.55E+002	1.946E+005	3.184E+002	4.081E-003
7.60E+002	1.962E+005	3.184E+002	3.888E-003
7.65E+002	1.978E+005	3.184E+002	3.704E-003
7.70E+002	1.994E+005	3.184E+002	3.529E-003
7.75E+002	2.010E+005	3.184E+002	3.362E-003
7.80E+002	2.026E+005	3.185E+002	3.202E-003
7.85E+002	2.042E+005	3.185E+002	3.051E-003
7.90E+002	2.058E+005	3.185E+002	2.906E-003
7.95E+002	2.073E+005	3.185E+002	2.769E-003
8.00E+002	2.089E+005	3.185E+002	2.638E-003
8.05E+002	2.105E+005	3.185E+002	2.513E-003
8.10E+002	2.121E+005	3.185E+002	2.394E-003
8.15E+002	2.137E+005	3.186E+002	2.280E-003
8.20E+002	2.153E+005	3.186E+002	2.172E-003
8.25E+002	2.169E+005	3.186E+002	2.069E-003
8.30E+002	2.185E+005	3.186E+002	1.971E-003
8.35E+002	2.201E+005	3.186E+002	1.878E-003
8.40E+002	2.217E+005	3.186E+002	1.789E-003
8.45E+002	2.233E+005	3.186E+002	1.704E-003
8.50E+002	2.249E+005	3.186E+002	1.623E-003
8.55E+002	2.265E+005	3.186E+002	1.547E-003
8.60E+002	2.281E+005	3.186E+002	1.473E-003
8.65E+002	2.296E+005	3.186E+002	1.403E-003
8.70E+002	2.312E+005	3.187E+002	1.337E-003
8.75E+002	2.328E+005	3.187E+002	1.274E-003
8.80E+002	2.344E+005	3.187E+002	1.213E-003
8.85E+002	2.360E+005	3.187E+002	1.156E-003
8.90E+002	2.376E+005	3.187E+002	1.101E-003
8.95E+002	2.392E+005	3.187E+002	1.049E-003
9.00E+002	2.408E+005	3.187E+002	9.991E-004
Image (c.t.)
Image

WebPilot
Posts: 3716
Joined: Tue Dec 07, 2004 6:51 pm
Antipspambot question: 0
Location: 41d 1' N 80d 22' W

Re: Back to Basic

Post by WebPilot » Sat Feb 20, 2010 12:39 am

 Working on the comparison of the results from two approximate methods with those of an analytical test experiment. Details soon.
Image

WebPilot
Posts: 3716
Joined: Tue Dec 07, 2004 6:51 pm
Antipspambot question: 0
Location: 41d 1' N 80d 22' W

Re: Back to Basic

Post by WebPilot » Sat Feb 20, 2010 10:30 pm

 OK, I've two methods that I am comparing.
  • Euler
  • Feynman-Newton
Image

WebPilot
Posts: 3716
Joined: Tue Dec 07, 2004 6:51 pm
Antipspambot question: 0
Location: 41d 1' N 80d 22' W

Re: Back to Basic

Post by WebPilot » Sun Feb 21, 2010 7:13 am

Image
Image

Post Reply