Subscribe in a reader

Pages vues depuis décembre 2009

mardi 30 septembre 2014

Gravitational acceleration inside a sphere : a program with or without bugs ?

by Yanick Toutain

Here is the code for my provisional program. I see no real bug 
The fact that my program examines only one quarter of the sphere should not be a problem for the final calculation of proportionality .... 
Unless ..... I am too tired to notice!

I DONT SEE ANY BUG
AND YOU ?

for a sphere with same density
% of radius acceleration
10,00% 1 m/s²
20,00% 2 m/s²
30,00% 3 m/s²
40,00% 4 m/s²
50,00% 5 m/s²
60,00% 6 m/s²
70,00% 7 m/s²
80,00% 8 m/s²
90,00% 8,98 m/s²
100,00% 9,81 m/s²



+++++
THE LANGAGE DOWNLOAD IS HERE
FreeBASIC Programming Language
THE CODE
SCREEN 19,32
DIM AS DOUBLE accpete, accfuge,vol,pi,scale,PROPGRAV
DIM AS INTEGER I, J,K,L,M,N,TOTAL
PI=3.1415926
N=20
N*=10
'L=250
L=N
vol=1/3*Pi*N^3
PRINT "vol/4 = "; 1/3*Pi*N^3
SCALE = N/100
DO 
 LOCATE 1,40
 PRINT "STARS ";TOTAL;" fract STARS/(VOL/4) :" ;TOTAL/VOL
    TOTAL=0
    accpete=0
    accfuge=0
    


FOR I= -N-1 TO L+1
    FOR J= 1 TO 1+int (SQR(N^2-I^2))
        FOR K= 1 TO 1+int (SQR(N^2-I^2-J^2))
            PSET (300+I/SCALE,400-J/SCALE),255
            TOTAL+=1
            accpete+=-(L-I)/((L-I)^2+J^2+K^2)^1.5
            'locate 20,20
            'PRINT ACCPETE
        NEXT K
    NEXT J
     locate 2,2
    PRINT ACCPETE
NEXT I
'PRINT TOTAL, VOL, ,accpete
PRINT TOTAL/VOL;
FOR I= L+2 TO N+1
    FOR J= 1 TO 1+int (SQR(N^2-I^2))
        FOR K= 1 TO 1+int (SQR(N^2-I^2-J^2))
           PSET (300+I/SCALE,400-J/SCALE), &hD2E6FF
            TOTAL+=1
            accfuge+=-(L-I)/((L-I)^2+J^2+K^2)^1.5
             'locate 20,30
            'PRINT ACCFUGE
        NEXT K
    NEXT J
    locate 3,2
    PRINT ACCFUGE
NEXT I


IF L=N THEN
    PROPGRAV= 9.81/accpete
    locate 2,25
    PRINT "  PROPGRAV   ";PROPGRAV
    SLEEP
END IF

LOCATE 7+10*L/N,0
PRINT L;" acpete "; accpete;" acfuge "; accfuge;" "; accfuge+accpete;" ";
IF (accfuge+accpete)*PROPGRAV>1 THEN 
    PRINT (accfuge+accpete)*PROPGRAV
ELSE
    PRINT 0
END IF

    
 L-=N/10
LOOP UNTIL L<0 font="" nbsp="">

ligne inutile ajouté par l'éditeur HTML> data-blogger-escaped-span="">
SLEEP
            
        
    
            
        
    
+++++

Aucun commentaire:

Enregistrer un commentaire