Προγραμματισμός με Εφαρμογές στην Επιστήμη του Μηχανικού

Μήπως να ξανακάνω Μηχανογραφικό;

Συντονιστές: φιάλη klein, Ryu, markelos, meleneemil, Nasia!

Απάντηση
alexk
Δημοσιεύσεις: 237
Εγγραφή: Τρί Ιαν 22, 2008 1:58 pm
Real Name: alex
Gender: Male

Re: Προγραμματισμός με Εφαρμογές στην Επιστήμη του Μηχανικού

Δημοσίευση από alexk »

sunday έγραψε:Εγώ αυτό έγραψα για το 6 τώρα το αν ειναι σωστό παίζεται..Το έκανα βάσει του θ.4

Κώδικας: Επιλογή όλων

 program Newton_Raphson
     
      implicit none
      integer P,i
      parameter(P=50)
      real  x(P)
      real x0,e,ei
      real f,fd
       

      print *,"# Enter x0:"
      read(5,*)x0
      print *,"# Enter the error:"
      read(5,*)e
       
      if (e .le. 0.0) stop 'illegal value of error'
      i=2
      x(1)=x0 

      open(unit=20,file="newton_r2.dat")
      write(20,*)1,x(1)

      do while(i .le. P)
      x(i)=x(i-1)-f(x(i-1))/fd(x(i-1))
      ei=abs(x(i)-x(i-1))/x(i)
      print *,i,x(i)
      write(20,*)i,x(i),ei
      if (ei .le. e) stop 'Procedure completed successfully'
      i=i+1
      enddo
      print *,'# Method failed after P=',P,'iterations'
      close(20)
      end
     
      real function f(x)
      implicit none
      real x
      f=sqrt(2.0)*x*(1-x)-x
      return
      end
     
      real function fd(x)
      implicit none
      real x
      fd=sqrt(2.0)+2*sqrt(2.0)*x-1
      return
      end
      
Βασικά έχω κάποιες ενστάσεις...
Αρχικά το προγραμμα περιοριζεται απ το Ρ=50 στις επαναληψεις.Δλδ αν μετα απο 50 επαναληψεις δεν δωσει αποτελεσμα σταματαει. Ισως να χρειαζοταν ας πουμε 51 κ λογω του περιορισμου να μην καταφερνει να βρει λυση.
-Μετα σχετικα με καποιες συμβασεις. To ei που βαζεις ειναι προφανως το σφαλμα κατα την τρεχουσα επαναληψη. Γιατι πρεπει να ειναι (x(i)-x(i-1))/x(i) και οχι χ(i)-x(i-1) ? Αυτο απλα στο ρωταω γιατι στο Β τομο στο βιβλιο στη σελιδα 16 εκει που γραφει "Η αναδρομικη σχεση (21)........πρεπει να ειναι σκετο x(i)-x(i-1)
-Ενταξει τα function σου υπολογιζουν για r=sqrt 2 οποτε για r = 2.124 πρεπει να αλλαξεις το function. ΟΚ. Απλα το λεω γιατι θα μπορουσες να του ζητας στην αρχη να σου δωσει το r...

Παραθετω ενα προγραμμα που εφτιαξα εγω με βαση το bifurcationPoints.f το οποιο μου το θυμιζει πολυ...βγαζουμε πολυ διαφορετικα αποτελεσματα.Τωρα ποιο ειναι σωστο ο θεος κ η ψυχη του..

Κώδικας: Επιλογή όλων

      program thema6
      implicit none
      real*8  r,x0,tol,error
      integer P
      parameter (P=100)
      real x(P)
      integer i

C ---- Input:
    
      print *,'# Enter r,x0,tol:'
      read(5,*) r,x0,tol
      print *,'# r= ',r, ' x0= ',x0,' tol= ',tol

C ---- Initialize:
     
      x(1) = x0
      error = 1  
      i = 1
      print*,i,x(1)
      i=2

C-----Compute
      
      do while (error .gt. tol)
         x(i) = x(i-1)-(r*x(i-1)*(1-x(i-1))-x(i-1))/(r*(1-2*x(i-1))-1)
         error =abs( x(i)-x(i-1))
         print *,i,x(i),error
         i = i+1
      enddo

      end
alexk
Δημοσιεύσεις: 237
Εγγραφή: Τρί Ιαν 22, 2008 1:58 pm
Real Name: alex
Gender: Male

Re: Προγραμματισμός με Εφαρμογές στην Επιστήμη του Μηχανικού

Δημοσίευση από alexk »

Tsakalos έγραψε:Εκανα το πρωτο ερωτημα απο το θεμα 7 και μου φαινεται οτι παιζει σωστα. To εγραψα απο κατω αν θελετε να το τσεκαρετε.
Στην τροχια μου βγαζει τα γνωστα σχηματακια λισαζου!
Ξερετε πως θα υπολογισουμε την ενεργεια? Λογικα για την κινητικη ενεργεια θα βρουμε τη συνισταμενη ταχυτητα αφου οι ταχυτητες ειναι καθετες v=ριζα(vx^2+vy^2) σωστα?
Η δυναμικη ενεργεια ομως πως βγαινει??
Τωρα θα δοκιμασω και το θεμα 6 ενω ακομα δεν εχω κανει καμια ασκηση με τη βλακεια τη λογιστικη εξισωση :evil:

Κώδικας: Επιλογή όλων

      program kinisi
      implicit none
      real*8 t,tf,dt,x0,y0,w1,w2,vx,vy,ax,ay,x,y
c------INPUT
      print *, 'enter x0, y0, w1, w2, tf, dt'
      read(5,*) x0, y0, w1, w2,tf,dt
      print *, 'ok malaka'
c------INITIALIZE
      x=x0
      y=y0
      t=0
      open(unit=11,file='kinisi.dat')
c------COMPUTE
      do while (t .le. tf)
         x = x0*cos(w1*t)
         vx=(x0/w1)*sin(w1*t)
         ax=(-x0/(w1*w1))*cos(w1*t)
         y=y0*sin(w2*t)
         vy=(-y0/w2)*cos(w2*t)
         ay=(-y0/(w2*w2))*sin(w2*t)                        
         t=t+dt
         write(11,*)t,x,y,vx,vy,ax,ay
      enddo
      close(11)
      end

Γιατί η ταχύτητα είναι vx=(x0/w1)*sin(w1*t) και οχι vx = -w1*x0*sin(w1*t) που είναι η παραγωγος του dx(t)/dt ??
Ομοια και για την επιταχυνση...

Εγω εχω φτιαξει αυτο που μεσες ακρες ειναι το ιδιο στην λογικη με το δικο σου...

Κώδικας: Επιλογή όλων

      program thema7
      implicit none
      
      real*8 x0,y0,omega1,omega2,tf,t,dt
      real*8 x,y,vx,vy,ax,ay,t0
      integer i
      

      print*,'# Enter x0,y0,omega1,omega2,tf,dt:'
      read(5,*)x0,y0,omega1,omega2,tf,dt
      
      
      print*,'x0 =',x0,'y0 =',y0,'omega1 =',omega1,'omega2 =',omega2,
     $     'tf =',tf,'dt =',dt
      
      t=0.0D0
      i = 0
      x=x0
      y=y0
      open(unit=11,file='thesi.dat')
      open(unit=12,file='taxythta.dat')
      open(unit=13,file='epitaxynsh.dat')
      do while (t .le. tf)
         i = i +1
         t = t0 + i*dt
         x = x*dcos(omega1*t)
         y = y*dsin(omega2*t)
         write(11,*)t,x,y
         vx = -omega1*x*dsin(omega1*t)
         vy = omega2*y*dcos(omega2*t)
         write(12,*)t,vx,vy
         ax = -omega1*omega1*x*dcos(omega1*t)
         ay = -omega2*omega2*y*dsin(omega2*t)
         write(13,*)t,ax,ay
      enddo
      close(11)
      close(12)
      close(13)
      
      end
Άβαταρ μέλους
Tsakalos
Δημοσιεύσεις: 518
Εγγραφή: Δευ Νοέμ 06, 2006 1:43 am
Real Name: Κώστας
Gender: Male
Facebook ID: 0
Τοποθεσία: Άλφα του Κενταύρου
Επικοινωνία:

Re: Προγραμματισμός με Εφαρμογές στην Επιστήμη του Μηχανικού

Δημοσίευση από Tsakalos »

ουπςςς! τι βλακας εκανα ολοκληρωμα αντι για παραγωγο μαλλον θα φταιει το πολυ διαβασμα αναλυσης 2 :rolleyes:
Το δικο σου ειναι το σωστο και κανει κ ακριβως αυτα που ζηταει η ασκηση! Με τις ενεργειες ξερει κανεις τι παιζει?
Τελευταία προτεραιότητα η σχολή μου!
και να θυμομόστε τον κύριο Dio...
Εικόνα
alexk
Δημοσιεύσεις: 237
Εγγραφή: Τρί Ιαν 22, 2008 1:58 pm
Real Name: alex
Gender: Male

Re: Προγραμματισμός με Εφαρμογές στην Επιστήμη του Μηχανικού

Δημοσίευση από alexk »

Tsakalos έγραψε:ουπςςς! τι βλακας εκανα ολοκληρωμα αντι για παραγωγο μαλλον θα φταιει το πολυ διαβασμα αναλυσης 2 :rolleyes:
Το δικο σου ειναι το σωστο και κανει κ ακριβως αυτα που ζηταει η ασκηση! Με τις ενεργειες ξερει κανεις τι παιζει?
Απο το θεμα 8 που εκανε ο Αναγνωστοπουλος πρεπει να ειναι τα ιδια.
Για την δυναμικη ενεργεια U = - ολοκληρωμα (F*dx) ==> U/m= - ολοκληρωμα (a (x)) , οπου a(x) ειναι η επιταχυνση. Οποτε κανεις στο χαρτι το ολοκληρωμα κ το δινεις να το βαρεσει για t......dt το προγραμμα.
Ολικη ενεργεια = Δυναμικη + Κινητικη ==> F/m = T/m + U/m = 1/2* U^2 + U όπου η κινητική ενεργεια ειναι 1/2*U^2 δλδ το μισο του τετραγωνου της δυναμικης..
Σου δειχνω και το προγραμμα του θεματος 8 για να δεις πως βαζει τις ενεργειες. Με παρομοιο τροπο μπαινουν και στο θεμα 7

Κώδικας: Επιλογή όλων

C     CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
C     Program to integrate equations of motion for accelerations
C     which are functions of x with the method of Euler, Euler-Cromer
C     and Euler-Verlet.
C     The user sets initial conditions and the subroutines return
C     X(t) and V(t)=dX(t)/dt in arrays T(1..STEPS),X(1..STEPS),V(1..STEPS)
C     The user provides number of integration STEPS and the final
C     time TFI.Initial time is assumed to be t_0=0 and the integration
C     step h = TFI/(STEPS-1) 
C     The user programs a real function accel(x) which gives the 
C     acceleration  dV(t)/dt as function of X.
C     NOTE: T(1) = 0 T(STEPS) = TFI and there are STEPS-1 aditional
C           steps after the initial point
C     CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
      program diff_eq_euler
      implicit none             ! We force ourselved to declare all variables
      integer P                 ! The size of the arrays, should be larger
      parameter(P=110000)       ! than number of steps
      real*8 T(P),X(P),V(P)       ! time t,x(t),v(t)=dx/dt
      real*8 Xin,Vin,Tfi          ! initial conditions
      real*8 Energy
      real*8 KineticE,PotentialE,accel !Allages!!
      integer steps,i
      !t_0 = 0.0

C     The user provides initial conditions X_0,V_0 final time t_f and
C     number of steps:
      print *,'Enter X_0,V_0,t_f,number of steps (t_0=0):'
      read(5,*)Xin,Vin,Tfi,steps
C     This check is necessary to avoid memory violations:
      if(steps .ge. p )then 
       print *,'steps must be strictly less than p. steps,p= ',steps,p
       stop
      endif

C     Xin= X(1), Vin=V(1), T(1)=0 and the routine gives eveolution in
C     T(2..STEPS), X(2..STEPS), V(2..STEPS) which we print in a file
      call euler(Xin,Vin,Tfi,steps,T,X,V)
      open(unit=20,file="euler.dat") !filename euler.dat given here
      do i=1,steps
C     Each line in data file has time, position, velocity:
       Energy = 0.5D0*V(i)*V(i)
     $      + 0.5D0*39.47841760D0*X(i)*X(i)
     $      + 0.25D0*20.0D0*X(i)*X(i)*X(i)*X(i)
     $      + 10.0D0*X(i)
       write(20,*) T(i),X(i),V(i),Energy 
      enddo
      close(20) !we close the unit to be reused below

C     We repeat everything for each method
      call euler_cromer(Xin,Vin,Tfi,steps,T,X,V)
      open(unit=20,file="euler_cromer.dat")
      do i=1,steps
       Energy = 0.5D0*V(i)*V(i)
     $      + 0.5D0*39.47841760D0*X(i)*X(i)
     $      + 0.25D0*20.0D0*X(i)*X(i)*X(i)*X(i)
     $      + 10.0D0*X(i)
       write(20,*) T(i),X(i),V(i),Energy 
      enddo
      close(20)
      
      call euler_verlet(Xin,Vin,Tfi,steps,T,X,V)
      open(unit=20,file="euler_verlet.dat")
      open(unit=21,file="energy.dat")
      do i=1,steps
       KineticE   = 0.5D0*V(i)*V(i)
       PotentialE = 0.5D0*39.47841760D0*X(i)*X(i)
     $      + 0.25D0*20.0D0*X(i)*X(i)*X(i)*X(i)
     $      + 10.0D0*X(i)
       Energy = KineticE + PotentialE
       write(20,*) T(i),X(i),V(i),Energy
       write(21,*) T(i),X(i),accel(X(i)),KineticE,PotentialE,Energy
      enddo
      close(20)
      close(21)

      end


C     CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
C     Function which returns the value of acceleration at
C     position x used in the integration subroutines
C     euler, euler_cromer and euler_verlet
C     CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
      real*8 function accel(x)
      implicit none
      real*8 x
      accel = -39.47841760D0*x-20.0D0*x*x*x-10.0D0
      end

C     CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
C     Driver routine for integrating equations of motion 
C     using the Euler method
C     Input:
C     Xin=X(1), Vin=V(1) -- initial condition at t=0,
C     Tfi the final time and steps the number of steps of integration
C     (the initial point is counted as the first one)
C     Output:
C     The arrays T(1..steps), X(1..steps), V(1..steps) which 
C     gives x(t_i)=X(i), dx/dt(t_i)=V(i), t_i=T(i) i=1..steps
C     where for i=1 we have the initial condition.
C     CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
      subroutine euler(Xin,Vin,Tfi,steps,T,X,V)
      implicit none
      integer P
      parameter(P=110000)
      real*8 T(P),X(P),V(P) !time t,x(t),v(t)=dx/dt
      real*8 Xin,Vin,Tfi
      integer steps,i
      real*8 h,accel     !**Note: we have to declare the function accel**
C     Initial conditions set here:      
      T(1) = 0.0D0
      X(1) = Xin
      V(1) = Vin
C     h is the time step Dt
      h    = Tfi/(steps-1)
      do i = 2,steps
       T(i) = T(i-1)+h          ! time advances by Dt
       X(i) = X(i-1)+V(i-1)*h   ! advancement and storage of position
       V(i) = V(i-1)+accel(X(i-1))*h !... and velocity. Here we call accel(x)
      enddo

      end

C     CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
C     Driver routine for integrating equations of motion 
C     using the Euler-Cromer method
C     Input:
C     Xin=X(1), Vin=V(1) -- initial condition at t=0,
C     Tfi the final time and steps the number of steps of integration
C     (the initial point is counted as the first one)
C     Output:
C     The arrays T(1..steps), X(1..steps), V(1..steps) which 
C     gives x(t_i)=X(i), dx/dt(t_i)=V(i), t_i=T(i) i=1..steps
C     where for i=1 we have the initial condition.
C     CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
      subroutine euler_cromer(Xin,Vin,Tfi,steps,T,X,V)
      implicit none
      integer P
      parameter(P=110000)
      real*8 T(P),X(P),V(P) !time t,x(t),v(t)=dx/dt
      real*8 Xin,Vin,Tfi
      integer steps,i
      real*8 h,accel
      
      T(1) = 0.0
      X(1) = Xin
      V(1) = Vin
      h    = Tfi/(steps-1)
      do i = 2,steps
       T(i) = T(i-1)+h
       V(i) = V(i-1)+accel(X(i-1))*h
       X(i) = X(i-1)+V(i)*h  !here is the difference compared to Euler
      enddo

      end

C     CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
C     Driver routine for integrating equations of motion 
C     using the Euler - Verlet method
C     Input:
C     Xin=X(1), Vin=V(1) -- initial condition at t=0,
C     Tfi the final time and steps the number of steps of integration
C     (the initial point is counted as the first one)
C     Output:
C     The arrays T(1..steps), X(1..steps), V(1..steps) which 
C     gives x(t_i)=X(i), dx/dt(t_i)=V(i), t_i=T(i) i=1..steps
C     where for i=1 we have the initial condition.
C     CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
      subroutine euler_verlet(Xin,Vin,Tfi,steps,T,X,V)
      implicit none
      integer P
      parameter(P=110000)
      real*8 T(P),X(P),V(P) !time t,x(t),v(t)=dx/dt
      real*8 Xin,Vin,Tfi
      integer steps,i
      real*8 h,g_over_l
      parameter(g_over_l=10.0D0)
      real*8 h2,X0,o2h
      real*8 accel

C     Initial conditions set here:
      T(1)    = 0.0D0
      X(1)    = Xin
      V(1)    = Vin
      h       = Tfi/(steps-1)   ! time step
      h2      = h*h             ! time step squared
      o2h     = 0.5D0/h           ! h/2
C     We have to initialize one more step: X0 corresponds to 'X(0)'
      X0      =     X(1)   - V(1) * h + accel(X(1))  *h2/2.0D0
      T(2)    = h
      X(2)    = 2.0D0*X(1)   - X0       + accel(X(1))  *h2
C     Now i starts from 3:      
      do i    = 3,steps
       T(i)   = T(i-1)+h
       X(i)   = 2.0D0*X(i-1) - X(i-2)   + accel(X(i-1))*h2
       V(i-1) = o2h * (X(i)-X(i-2))
      enddo
C     Notice that we have one more step for the velocity:
      V(steps)= (X(steps)-X(steps-1))/h 

      end

Άβαταρ μέλους
markelos
Portal Moderator
Portal Moderator
Δημοσιεύσεις: 316
Εγγραφή: Σάβ Αύγ 18, 2007 8:57 pm
Real Name: Ace
Gender: Male
Facebook ID: 0
Τοποθεσία: Grand Line

Re: Προγραμματισμός με Εφαρμογές στην Επιστήμη του Μηχανικού

Δημοσίευση από markelos »

Tsakalos έγραψε:ουπςςς! τι βλακας εκανα ολοκληρωμα αντι για παραγωγο μαλλον θα φταιει το πολυ διαβασμα αναλυσης 2 :rolleyes:
Το δικο σου ειναι το σωστο και κανει κ ακριβως αυτα που ζηταει η ασκηση! Με τις ενεργειες ξερει κανεις τι παιζει?
Κλοπυ-πειστ πάλι την euler_verlet από το αρχείο euler.f που έχουμε για ξεπατικωτούρα.
Οι αλλαγές είναι η δήλωση των Energy, KineticE, PotentialE, το άνοιγμα ενός αρχείου energy.dat καθώς και η αλλαγή της επιτάχυνσης (accel).

Κώδικας: Επιλογή όλων

C     CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
C     Program to integrate equations of motion for accelerations
C     which are functions of x with the method of Euler, Euler-Cromer
C     and Euler-Verlet.
C     The user sets initial conditions and the subroutines return
C     X(t) and V(t)=dX(t)/dt in arrays T(1..STEPS),X(1..STEPS),V(1..STEPS)
C     The user provides number of integration STEPS and the final
C     time TFI.Initial time is assumed to be t_0=0 and the integration
C     step h = TFI/(STEPS-1) 
C     The user programs a real function accel(x) which gives the 
C     acceleration  dV(t)/dt as function of X.
C     NOTE: T(1) = 0 T(STEPS) = TFI and there are STEPS-1 aditional
C           steps after the initial point
C     CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
      program diff_eq_euler
      implicit none             ! We force ourselved to declare all variables
      integer P                 ! The size of the arrays, should be larger
      parameter(P=110000)       ! than number of steps
      real*8 T(P),X(P),V(P)       ! time t,x(t),v(t)=dx/dt
      real*8 Xin,Vin,Tfi          ! initial conditions
      real*8 Energy
      real*8 KineticE, PotentialE, accel !Allages!!
      integer steps,i
      !t_0 = 0.0

C     The user provides initial conditions X_0,V_0 final time t_f and
C     number of steps:
      print *,'Enter X_0,V_0,t_f,number of steps (t_0=0):'
      read(5,*)Xin,Vin,Tfi,steps
C     This check is necessary to avoid memory violations:
      if(steps .ge. p )then 
       print *,'steps must be strictly less than p. steps,p= ',steps,p
       stop
      endif

      call euler_verlet(Xin,Vin,Tfi,steps,T,X,V)
      open(unit=20,file="euler_verlet.dat")
      open(unit=21,file="energy.dat")
      do i=1,steps
       KineticE   = 0.5D0*V(i)*V(i)
       PotentialE = 0.5D0*39.478417D0*X(i)*X(i)
     $      +0.25D0*20.0D0*X(i)*X(i)*X(i)*X(i)   !X(i)**4
     $      +10.0D0*X(i)
       Energy = KineticE+PotentialE
       write(20,*) T(i),X(i),V(i),Energy 
       write(21,*) T(i),X(i),accel(X(i)),KineticE,PotentialE,Energy
      enddo
      close(20)
      close(21)
      end


C     CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
C     Function which returns the value of acceleration at
C     position x used in the integration subroutines
C     euler, euler_cromer and euler_verlet
C     CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
      real*8 function accel(x)
      implicit none
      real*8 x
      accel = -39.4784176D0*x-20.0D0*x*x*x-10.0D0
      end


C     CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
C     Driver routine for integrating equations of motion 
C     using the Euler - Verlet method
C     Input:
C     Xin=X(1), Vin=V(1) -- initial condition at t=0,
C     Tfi the final time and steps the number of steps of integration
C     (the initial point is counted as the first one)
C     Output:
C     The arrays T(1..steps), X(1..steps), V(1..steps) which 
C     gives x(t_i)=X(i), dx/dt(t_i)=V(i), t_i=T(i) i=1..steps
C     where for i=1 we have the initial condition.
C     CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
      subroutine euler_verlet(Xin,Vin,Tfi,steps,T,X,V)
      implicit none
      integer P
      parameter(P=110000)
      real*8 T(P),X(P),V(P) !time t,x(t),v(t)=dx/dt
      real*8 Xin,Vin,Tfi
      integer steps,i
      real*8 h,g_over_l
      parameter(g_over_l=10.0D0)
      real*8 h2,X0,o2h
      real*8 accel

C     Initial conditions set here:
      T(1)    = 0.0D0
      X(1)    = Xin
      V(1)    = Vin
      h       = Tfi/(steps-1)   ! time step
      h2      = h*h             ! time step squared
      o2h     = 0.5D0/h           ! h/2
C     We have to initialize one more step: X0 corresponds to 'X(0)'
      X0      =     X(1)   - V(1) * h + accel(X(1))  *h2/2.0D0
      T(2)    = h
      X(2)    = 2.0D0*X(1)   - X0       + accel(X(1))  *h2
C     Now i starts from 3:      
      do i    = 3,steps
       T(i)   = T(i-1)+h
       X(i)   = 2.0D0*X(i-1) - X(i-2)   + accel(X(i-1))*h2
       V(i-1) = o2h * (X(i)-X(i-2))
      enddo
C     Notice that we have one more step for the velocity:
      V(steps)= (X(steps)-X(steps-1))/h 

      end
Τελευταία επεξεργασία από το μέλος markelos την Δευ Ιουν 14, 2010 11:48 pm, έχει επεξεργασθεί 1 φορά συνολικά.
alexk
Δημοσιεύσεις: 237
Εγγραφή: Τρί Ιαν 22, 2008 1:58 pm
Real Name: alex
Gender: Male

Re: Προγραμματισμός με Εφαρμογές στην Επιστήμη του Μηχανικού

Δημοσίευση από alexk »

Αυτο με την ελλειψη που ζηταει στο πρωτο ερωτημα και στο τελευταιο στο θεμα 7 καταλαβε κανεις τι γινεται?
sunday
Δημοσιεύσεις: 43
Εγγραφή: Τετ Μάιος 23, 2007 10:59 am

Re: Προγραμματισμός με Εφαρμογές στην Επιστήμη του Μηχανικού

Δημοσίευση από sunday »

Βασικά έχω κάποιες ενστάσεις...
Αρχικά το προγραμμα περιοριζεται απ το Ρ=50 στις επαναληψεις.Δλδ αν μετα απο 50 επαναληψεις δεν δωσει αποτελεσμα σταματαει. Ισως να χρειαζοταν ας πουμε 51 κ λογω του περιορισμου να μην καταφερνει να βρει λυση.
-Μετα σχετικα με καποιες συμβασεις. To ei που βαζεις ειναι προφανως το σφαλμα κατα την τρεχουσα επαναληψη. Γιατι πρεπει να ειναι (x(i)-x(i-1))/x(i) και οχι χ(i)-x(i-1) ? Αυτο απλα στο ρωταω γιατι στο Β τομο στο βιβλιο στη σελιδα 16 εκει που γραφει "Η αναδρομικη σχεση (21)........πρεπει να ειναι σκετο x(i)-x(i-1)
-Ενταξει τα function σου υπολογιζουν για r=sqrt 2 οποτε για r = 2.124 πρεπει να αλλαξεις το function. ΟΚ. Απλα το λεω γιατι θα μπορουσες να του ζητας στην αρχη να σου δωσει το r...

Παραθετω ενα προγραμμα που εφτιαξα εγω με βαση το bifurcationPoints.f το οποιο μου το θυμιζει πολυ...βγαζουμε πολυ διαφορετικα αποτελεσματα.Τωρα ποιο ειναι σωστο ο θεος κ η ψυχη του..

Κώδικας: Επιλογή όλων

      program thema6
      implicit none
      real*8  r,x0,tol,error
      integer P
      parameter (P=100)
      real x(P)
      integer i

C ---- Input:
    
      print *,'# Enter r,x0,tol:'
      read(5,*) r,x0,tol
      print *,'# r= ',r, ' x0= ',x0,' tol= ',tol

C ---- Initialize:
     
      x(1) = x0
      error = 1  
      i = 1
      print*,i,x(1)
      i=2

C-----Compute
      
      do while (error .gt. tol)
         x(i) = x(i-1)-(r*x(i-1)*(1-x(i-1))-x(i-1))/(r*(1-2*x(i-1))-1)
         error =abs( x(i)-x(i-1))
         print *,i,x(i),error
         i = i+1
      enddo

      end
[/quote]

για τις επαναλήψεις δεν ξερω θέλω να πιστεύω οτι αν μας βάλουν κάτι ανάλογο θα μας δώσουν συγκεκριμένο αριθμό,για το σφάλμα χ(ι)-χ(ι-1) είναι το απόλυτο σφάλμα, ενώ διαιρεμένο με το χ(ι) είναι το σχετικό σφάλμα. Τώρα πιο από τα δύο είναι σωστό δεν έχω ιδεα :?
Semfitakos
Δημοσιεύσεις: 17
Εγγραφή: Κυρ Μαρ 21, 2010 7:21 pm
Real Name: Jim
Gender: Male
Facebook ID: 0

Re: Προγραμματισμός με Εφαρμογές στην Επιστήμη του Μηχανικού

Δημοσίευση από Semfitakos »

Mia ilithia erotisi...??^%%&%

Stin ekfrasi x = r*x*dexp(-x)

to d ti dhl;vnei mprosta apo to exp(-x)???

Efxaristo!!!
alexk
Δημοσιεύσεις: 237
Εγγραφή: Τρί Ιαν 22, 2008 1:58 pm
Real Name: alex
Gender: Male

Re: Προγραμματισμός με Εφαρμογές στην Επιστήμη του Μηχανικού

Δημοσίευση από alexk »

Semfitakos έγραψε:Mia ilithia erotisi...??^%%&%

Stin ekfrasi x = r*x*dexp(-x)

to d ti dhl;vnei mprosta apo to exp(-x)???

Efxaristo!!!
Τπτ και να μη βαλεις το d η ιδια δουλεια θα γινει. Κατι σχετικα με την ακριβεια εχει να κανει..
citizen
Δημοσιεύσεις: 29
Εγγραφή: Πέμ Ιαν 29, 2009 9:12 am
Real Name: Μάνος
Gender: Male
Facebook ID: 0

Re: Προγραμματισμός με Εφαρμογές στην Επιστήμη του Μηχανικού

Δημοσίευση από citizen »

Στο θέμα 6 έκανα ότι και ο sunday ,πρέπει να είναι σωστό.Μετά όμως τι χ0 θα διαλέξουμε για να τρέξει το πρόγραμμα?
Άβαταρ μέλους
vkvk
Δημοσιεύσεις: 76
Εγγραφή: Τετ Σεπ 23, 2009 11:08 am
Real Name: Vangelis
Gender: Male
Facebook ID: 0

Re: Προγραμματισμός με Εφαρμογές στην Επιστήμη του Μηχανικού

Δημοσίευση από vkvk »

Semfitakos έγραψε:Mia ilithia erotisi...??^%%&%

Stin ekfrasi x = r*x*dexp(-x)

to d ti dhl;vnei mprosta apo to exp(-x)???

Efxaristo!!!
double precision σημαίνει
o_apolytos
Δημοσιεύσεις: 962
Εγγραφή: Κυρ Οκτ 21, 2007 3:06 pm
Real Name: Πραγματικό Όνομα

Re: Προγραμματισμός με Εφαρμογές στην Επιστήμη του Μηχανικού

Δημοσίευση από o_apolytos »

Τί γίνεται; Ποια είναι τα θέματα τελικά; Υπάρχει κανένα νέο από το μέτωπο;
Άβαταρ μέλους
deee
Δημοσιεύσεις: 51
Εγγραφή: Τετ Φεβ 25, 2009 12:39 pm
Real Name: deee
Gender: Female
Facebook ID: 0

Re: Προγραμματισμός με Εφαρμογές στην Επιστήμη του Μηχανικού

Δημοσίευση από deee »

Εμένα δεν μου έχει έρθει mail.Μήπως έχουν βγει τα αποτελέσματα μόνο του β+γ τμήματος; :e_confused:
zoe
Δημοσιεύσεις: 34
Εγγραφή: Τετ Οκτ 24, 2007 2:02 pm
Real Name: Zwi
Gender: Female
Facebook ID: 517606286
Τοποθεσία: everywhere

Re: Προγραμματισμός με Εφαρμογές στην Επιστήμη του Μηχανικού

Δημοσίευση από zoe »

Ούτε εμένα..Μάλλον του Α' τμήματος δεν τα εχουν βγάλει..
o_apolytos
Δημοσιεύσεις: 962
Εγγραφή: Κυρ Οκτ 21, 2007 3:06 pm
Real Name: Πραγματικό Όνομα

Re: Προγραμματισμός με Εφαρμογές στην Επιστήμη του Μηχανικού

Δημοσίευση από o_apolytos »

αυτό ξέχασα να το βάλω, όντως, μόνο του Β' και Γ' τμήματος έχουνε βγει! Για το Α' δε ξέρω κάτι...
Απάντηση

Επιστροφή στο “Δεύτερο Έτος”