qqcreafis
| Inviato il: 05/02/2015 20:02:04
|
rimando il programma che sembra corretto con il girotondo
REM ***** BASIC *****
Sub Main
dim psi(999,9999) As Double ' matricetempo lunghezza
dim AAA(9999) As Double ' buffer
dim BBB(9999) As Double ' buffer
dim CCC(9999) As Double ' buffer
dim Rho As Double ' densità fluido
dim V0 As Double ' velocità iniziale colonna
dim deltat As Double ' intervallo di tempo
dim N As Integer ' numero di interazioni tra due visualizzazioni
dim tot As Double 'tempo totale simulazione
dim tintermedio As Double 'tempo N*deltat
dim ltot As Double ' lunghezza ariete
dim L0 As Double ' distanza tra segmenti L0=ltot/10000
dim B As Double ' compressibilità
dim Vfase As Double ' velocità sperimentale
dim D As Double ' diametro ariete
dim P As Double ' pressione contraria
dim F As Double ' forza contraria
dim A As Double ' area sezione
dim I,J,K,nitertemp As Integer ' contatori
Dim Doc As Object
Dim Sheet As Object
Dim Cell As Object
'Valori
'Rho=1000 'densità kg/m^3
'ltot = 2 'lunghezza ariete metri
' Vfase = 30 'velocita fase onda sperimentale m/s
'V0 = 5.5 'velocità ariete m/s
Doc = StarDesktop.CurrentComponent
Sheet = Doc.Sheets(0)
Cell = Sheet.getCellByPosition(0, 1)
Rho=Cell.Value
Cell = Sheet.getCellByPosition(2, 1)
Vfase=Cell.Value
Cell = Sheet.getCellByPosition(4, 1)
V0=Cell.Value
Cell = Sheet.getCellByPosition(6, 1)
ltot = Cell.Value
Cell = Sheet.getCellByPosition(7, 1)
D = Cell.Value
Cell = Sheet.getCellByPosition(9, 1)
deltat = Cell.Value
Cell = Sheet.getCellByPosition(10, 1)
N = Cell.Value
Cell = Sheet.getCellByPosition(11, 1)
P =10000*Cell.Value
Cell = Sheet.getCellByPosition(16, 1)
nitertemp=Cell.Value
A=3.14*D^2/4
F=P*A
Cell = Sheet.getCellByPosition(15, 1)
Cell.Value = F
tot = deltat*nitertemp
Cell = Sheet.getCellByPosition(12, 1)
Cell.Value =tot
B=Vfase*Vfase*Rho
Cell = Sheet.getCellByPosition(14, 1)
Cell.Value = B
L0=ltot/10000
Cell = Sheet.getCellByPosition(13, 1)
Cell.Value =L0
'inizializzazione
Cell = Sheet.getCellByPosition(3, 3)
Cell.String = "inizio"
psi(0,0)= 0
AAA(0)=psi(0,0)
for I=1 to 9999
psi(0,I)= L0+psi(0,I-1) 'prima colonna nel foglio "A"
AAA(I)=psi(0,I)
next I
'primo spostamento V0*deltat +psi precedente
for I=0 to 9999
' psi(1,I)= psi(0,I)-V0*deltat ' seconda colonna "B"
BBB(I)= AAA(I)-V0*deltat
next I
'girotondo 0
'psi(j,0) = 2*psi(j-1,0)-psi(j-2,0)+1/Rho*(deltat/L0)^2*(P*L0+B*(psi(j-1,1)-psi(j-1,0)-L0))
CCC(0) = 2*BBB(0)-AAA(0)+1/Rho*(deltat/L0)^2*(P*L0+B*(BBB(1)-BBB(0)-L0))
for I=1 to 9998
CCC(I) = 2*BBB(I)-AAA(I)+B/Rho*(deltat/L0)^2*(BBB(I+1)-2*BBB(I)+BBB(I-1))
next I
'psi(j,9999) = 2*psi(j-1,9999)-psi(j-2,9999)+B/Rho*(deltat/L0)^2*(psi(j-1,9999)-psi(j-1,9998)-L0)
CCC(9999) = 2*BBB(9999)-AAA(9999)+B/Rho*(deltat/L0)^2*(BBB(9999)-BBB(9998)-L0)
for j=1 to nitertemp
'girotondo 1
For K = 0 to N-2
Cell = Sheet.getCellByPosition(6, 6)
Cell.Value = k
AAA(0) = 2*CCC(0)-BBB(0)+1/Rho*(deltat/L0)^2*(P*L0+B*(CCC(1)-CCC(0)-L0))
for I=1 to 9998
AAA(I) = 2*CCC(I)-BBB(I)+B/Rho*(deltat/L0)^2*(CCC(I+1)-2*CCC(I)+CCC(I-1))
next I
AAA(9999) = 2*CCC(9999)-BBB(9999)+B/Rho*(deltat/L0)^2*(CCC(9999)-CCC(9998)-L0)
'girotondo 2
BBB(0) = 2*AAA(0)-CCC(0)+1/Rho*(deltat/L0)^2*(P*L0+B*(AAA(1)-AAA(0)-L0))
for I=1 to 9998
BBB(I) = 2*AAA(I)-CCC(I)+B/Rho*(deltat/L0)^2*(AAA(I+1)-2*AAA(I)+AAA(I-1))
next I
'girotondo extra
BBB(9999) = 2*AAA(9999)-CCC(9999)+B/Rho*(deltat/L0)^2*(AAA(9999)-AAA(9998)-L0)
CCC(0) = 2*BBB(0)-AAA(0)+1/Rho*(deltat/L0)^2*(P*L0+B*(BBB(1)-BBB(0)-L0))
for I=1 to 9998
CCC(I) = 2*BBB(I)-AAA(I)+B/Rho*(deltat/L0)^2*(BBB(I+1)-2*BBB(I)+BBB(I-1))
next I
'psi(j,9999) = 2*psi(j-1,9999)-psi(j-2,9999)+B/Rho*(deltat/L0)^2*(psi(j-1,9999)-psi(j-1,9998)-L0)
CCC(9999) = 2*BBB(9999)-AAA(9999)+B/Rho*(deltat/L0)^2*(BBB(9999)-BBB(9998)-L0)
next k
for I=0 to 9999
psi(j,I)=CCC(I)
next I
If j=1 Then N=N+1
Cell = Sheet.getCellByPosition(5, 6)
Cell.Value = j
Cell = Sheet.getCellByPosition(j,10)
Cell.Value =psi(j,0)
Cell = Sheet.getCellByPosition(j,14)
Cell.Value =psi(j,9999)
'Cell = Sheet.getCellByPosition(j,12)
'Cell.Value =psi(j,2)
'Cell = Sheet.getCellByPosition(j,13)
'Cell.Value =psi(j,3)
next j
'for I=0 to 999
'Cell = Sheet.getCellByPosition(I,10)
'Cell.Value =psi(I,0)
'next I
'Cell = Sheet.getCellByPosition(5, 5)
'Cell.String = "o"
'for I=0 to 9999
'Cell = Sheet.getCellByPosition(0, I+10)
'Cell.Value =psi(0,I)
'next I
'for I=0 to 9999
'Cell = Sheet.getCellByPosition(1, I+10)
'Cell.Value =psi(1,I)
'next I
'for I=0 to 9999
'Cell = Sheet.getCellByPosition(2, I+10)
'Cell.Value =psi(2,I)
'next I
Cell = Sheet.getCellByPosition(6, 6)
Cell.String = "fine"
'Doc = StarDesktop.CurrentComponent
'Sheet = Doc.Sheets(0)
'Cell = Sheet.getCellByPosition(2, 0)
'Cell.String = "Test"
MsgBox Cell.Value
'
'
'
'
'
'
'
'
End Sub
Sub Macro1
End Sub
--------------- ODE AD UNO STUDENTE MERITEVOLE (Sermone) Allora Xyz è stato bravo! noi dobbiamo riconoscere che è stato molto bravo, bisogna dirlo ! In un mondo dove tutto SEMBRA uguale a tutto. In un mondo dove chi abbruttisce la dignità dell’intelligenza umana si arroga meriti. In un mondo in cui si dice che i giovani non hanno speranza perché “tanto non troveranno lavoro” perché tanto non “non avranno la pensione”. Xyz è stato bravo! ha capito tutto, ha fatto un compito perfetto. Xyz ci da una SPERANZA. Xyz non ha seguito le falsità che ci circondano. Xyz si è impegnato ed è riuscito nel suo intento.
|