IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Fortran Discussion :

l'equation de la chaleur


Sujet :

Fortran

  1. #1
    Candidat au Club
    Homme Profil pro
    Inscrit en
    Janvier 2012
    Messages
    7
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Algérie

    Informations professionnelles :
    Secteur : Enseignement

    Informations forums :
    Inscription : Janvier 2012
    Messages : 7
    Points : 3
    Points
    3
    Par défaut l'equation de la chaleur
    bonsoir monsieur ma dame
    moi je suis un étudiant en physique spatiale
    j'avais besoin d 'écrire un algorithme qui concerne l'équation de la propagation de la chaleur a 1 dimension
    j'ai fait le développement mathématique et le code source mais malheureusement pas marche
    SVP aider moi a faire ca et me corriger
    merci mon maitre et en attente de votre réponse
    le voici

    program equation de la chaleur
    implicit none
    parameter m, n, mmax=10, nmax=18
    real : alpha, detax, deltat
    common /temper/t(mmax,nmax)
    m=11
    n=18
    alpha=4.d-6
    deltax=1.d-2
    deltat=1.d0
    r=alpha*deltat/(detax)**2
    do j=1,1
    do i=1,m
    t(i,j)=300
    end do
    end do
    do j=2,n
    do i=1,1
    t(i,j)=350
    end do
    end do
    do j=2,n
    do i=m,m
    t(i,j)=440
    end do
    end do
    !methode explicite de resolution
    do j=1,n
    do i=2,m-1
    t(i,j+1)=r*t(i-1,j)+(1-2*r)*t(i,j)+r*t(i+1,j)
    end do
    end do
    do j=1,n
    write(12,10)j, (t(i,j),i=1,m)
    end do
    stop
    end program equation de la chaleur

  2. #2
    Candidat au Club
    Homme Profil pro
    Inscrit en
    Janvier 2012
    Messages
    7
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Algérie

    Informations professionnelles :
    Secteur : Enseignement

    Informations forums :
    Inscription : Janvier 2012
    Messages : 7
    Points : 3
    Points
    3
    Par défaut la methode explicit de resolution de l'equation
    salut tout le monde
    j'avais besoin d 'écrire un algorithme qui concerne l'équation de propagation de la chaleur a 1 dimension
    je fais le développement mathématique mais la compilation malheureusement ne marche pas
    SVP aider moi a faire ca et me corriger
    merci pour votre réponse
    le voici

    program heat
    implicit none
    integer::m,n
    integer:: i,j
    real::alpha,deltax,deltat,lx,lt,tinit,tlimg,tlimd,r
    real, dimension(m,n) :: t

    print*, "entrez alpha,lx,lt,deltax,deltat,tinit,tlimg,tlimd"
    read*, alpha,lx,lt,deltax,deltat,tinit,tlimg,tlimd
    m=INT((lx/deltax))+1
    n=INT((lt/deltat))+1

    r=alpha*deltat/(deltax)**2

    do i=1,m
    t(i,1)=tinit
    end do

    do j=2,n
    t(1,j)=tlimg
    end do

    do j=2,n
    t(m,j)=tlimd
    end do

    !methode explicite de resolution
    do j=1,n
    do i=2,m-1
    t(i,j+1)=r*t(i-1,j)+(1-2*r)*t(i,j)+r*t(i+1,j)
    end do
    end do

    do j=1,n
    write(1,*) j, (t(i,j),i=1,m)
    end do

    end program heat



    message du compilateur


    real, dimension(m,n) :: t
    1
    Error: Variable 'm' cannot appear in the expression at (1)
    heat2.f95:6.18:

    real, dimension(m,n) :: t
    1
    Error: Variable 'n' cannot appear in the expression at (1)
    heat2.f95:6.25:

    real, dimension(m,n) :: t
    1
    Error: The module or main program array 't' at (1) must have constant shape

  3. #3
    Candidat au Club
    Homme Profil pro
    Inscrit en
    Janvier 2012
    Messages
    7
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Algérie

    Informations professionnelles :
    Secteur : Enseignement

    Informations forums :
    Inscription : Janvier 2012
    Messages : 7
    Points : 3
    Points
    3
    Par défaut la solution exacte
    c'est la suite de la 1ere
    mais ici avec un exemple de la solution exacte
    y a des erreurs aider moi a le corriger SVP
    merci d'avance

    program anal
    implicit none
    real lx,lt,pi,lamb,lam1,lamb2,alpha,detax,deltat,xd,xn,som,an
    integer,parameter:: (n=101)
    real, dimension(m1,n1) :: t
    real,dimension(m1) :
    real,dimension(n1) ::y
    !real,dimension:: x(m),y(n),t(m,n)
    real fbar
    integer::i,j
    pi=acos(-1.0d0)
    lx=1
    lt=100
    alpha=0.01
    deltax=1.0d-2
    deltat=1
    m1=INT((lx/deltax))+1
    n1=INT((lt/deltat))+1
    fbar=300
    do j=1,n1
    y(j)=(j-1)*deltat
    end do
    nn=5
    do j=50,50
    do i=1,m1
    x(i)=(i-1)*deltax
    som=0
    do n=1,nn
    lamb=n*pi/lx
    lamb1=lamb*lx
    lamb2=alpha*y(j)*(lamb**2)
    xn=2*fbar*(1-cos(lamb1))
    xd=lamb1
    an=xn/xd
    som=som+an*(exp(-lamb2))sin*(lamb*x(i))
    t(i,j)=som
    end do
    end do
    end do
    do j=50,50
    do i=1,m1
    write(12,10) x(i),t(i,j)
    end do
    end do
    format(1x,f8.3,1x,f8.3)
    stop
    end program anal

  4. #4
    Candidat au Club
    Homme Profil pro
    Inscrit en
    Janvier 2012
    Messages
    7
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Algérie

    Informations professionnelles :
    Secteur : Enseignement

    Informations forums :
    Inscription : Janvier 2012
    Messages : 7
    Points : 3
    Points
    3
    Par défaut c la suite c nécessaire
    bonjour
    c'est le même problème mais ici avec une condition de convergence qu'on impose
    j'ai vraiment besoin de ce programme nécessaire insistant
    merci pour votre repense
    je vous prie d'agréer, mes salutations les plus distinguées.


    program heat
    implicit none
    integer::m,n
    integer:: i,j
    real::alpha,deltax,deltat,lx,lt,tinit,tlimg,tlimd,r
    real, dimension(m,n) :: t

    print*, "entrez alpha,lx,lt,deltax,deltat,tinit,tlimg,tlimd"
    read*, alpha,lx,lt,deltax,deltat,tinit,tlimg,tlimd
    m=INT((lx/deltax))+1
    n=INT((lt/deltat))+1

    r=alpha*deltat/(deltax)**2
    if r>0.5
    !repeter a entrez et a caculer r juseque r est inferieur ou egale a 0.5
    repeat
    print*,"le temps du pas choisi ne pas bon,enterez a nouveau deltat,deltax"
    read*, deltat,deltax
    r=alpha*deltat/(deltax)**2

    !until r<=0.5
    else
    print*, "le temps du pas choisi satisfait a la condition de convergeance"


    do i=1,m
    t(i,1)=tinit
    end do

    do j=2,n
    t(1,j)=tlimg
    end do

    do j=2,n
    t(m,j)=tlimd
    end do

    !methode explicite de resolution
    do j=1,n
    do i=2,m-1
    t(i,j+1)=r*t(i-1,j)+(1-2*r)*t(i,j)+r*t(i+1,j)
    end do
    end do

    do j=1,n
    write(1,*) j, (t(i,j),i=1,m)
    end do

    end program heat

  5. #5
    Membre habitué

    Homme Profil pro
    Développeur informatique
    Inscrit en
    Janvier 2012
    Messages
    27
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Aéronautique - Marine - Espace - Armement

    Informations forums :
    Inscription : Janvier 2012
    Messages : 27
    Points : 170
    Points
    170
    Par défaut
    Bonjour,
    c'est une erreur normale.
    Tu ne peux pas déclarer des tableau dynamiques de cette manière (real, dimension(m,n) :: t), il faut passer par la commande allocatable qui permet de gérer les tableaux dynamiques

    Il faut remplacer la définition par:
    real, dimension(:,:), allocatable :: t

    Ensuite, une fois que n et m ont été saisis par l'utilisateur, on peut allouer le tableau:
    allocate t(m,n)


    Ne pas oublier de désallouer le tableau à la fin:
    deallocate(t)

    Avec ces modifications, cela devrait compiler.

  6. #6
    Membre habitué

    Homme Profil pro
    Développeur informatique
    Inscrit en
    Janvier 2012
    Messages
    27
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Aéronautique - Marine - Espace - Armement

    Informations forums :
    Inscription : Janvier 2012
    Messages : 27
    Points : 170
    Points
    170
    Par défaut
    Bonjour,
    là honnêtement je ne sais pas si quelqu'un va pouvoir t'aider.
    Il y a plein de fautes (dans le désordre):
    • Regardes ton post précédent, j'ai répondu quelque chose a propo des tableaux dynamiques
    • Regardes tes variables, certaines ne sont pas déclarées
    • c'est sin( et non sin*
    • soit tu utilises des doubles précision et donc tout déclarer en temps que tel, soit des floats et tout utiliser en temps de tel (ne pas utiliser alors 1.d0)
    • tu fais des boucles sur un élément, je n'ai pas encore compris l'utilité
    • write(12,10) pas de référence à la balise 10 dans le code (balise de formatage)
    • ...

    J'avoue avoir commencé à rédiger un code corrigé, mais avoir laissé tombé au vue des erreurs trop nombreuses et grossières qui laissent fortement à penser à un code réalisé rapidement sur un bout de papier.
    De plus je pense qu'il y a également des problèmes au niveau de l'algorithmie, mais je ne comprends pas trop ce que tu cherchez à modéliser :/.
    Cordialement,
    Nanzilla.

  7. #7
    Candidat au Club
    Homme Profil pro
    Inscrit en
    Janvier 2012
    Messages
    7
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Algérie

    Informations professionnelles :
    Secteur : Enseignement

    Informations forums :
    Inscription : Janvier 2012
    Messages : 7
    Points : 3
    Points
    3
    Par défaut erreur interne d'execution
    bonjour
    le code était bien compile mais il y a une erreur du a l'exécution
    il me dit ca

    sous windows
    Runtime error from program:c:\users\bachtouti\desktop\go.exe
    Run-time Error
    *** Error 112, Reference to undefined variable, array element or function result (/UNDEF)

    main - in file go.f95 at line 12 [+01b7]

    et voici le code
    c'est le précèdent avec une amélioration

    program heat
    implicit none
    integer::m,n
    integer:: i,j
    real::alpha,deltax,deltat,lx,lt,tinit,tlimg,tlimd,r
    !real, dimension(m,n) :: t
    real, dimension(:,, allocatable :: t

    print*, "entrez alpha,lx,lt,deltax,deltat,tinit,tlimg,tlimd"
    read*, alpha,lx,lt,deltax,deltat,tinit,tlimg,tlimd

    allocate (t(m,n))
    m=INT((lx/deltax))+1
    n=INT((lt/deltat))+1

    r=alpha*deltat/(deltax)**2



    allocate (t(m,n))

    do i=1,m
    t(i,1)=tinit
    end do

    do j=2,n
    t(1,j)=tlimg
    end do

    do j=2,n
    t(m,j)=tlimd
    end do

    !methode explicite de resolution
    do j=1,n
    do i=2,m-1
    t(i,j+1)=r*t(i-1,j)+(1-2*r)*t(i,j)+r*t(i+1,j)
    end do
    end do




    do j=1,n
    write(1,*) j, (t(i,j),i=1,m)
    end do
    deallocate (t)

    end program heat







    si j'ai entre les donnes
    sous le gfortran il s'affiche le message suivant

    *** glibc detected *** ./a.out: free(): invalid next size (fast): 0x08b81068 ***
    ======= Backtrace: =========
    /lib/i386-linux-gnu/libc.so.6(+0x6ebc2)[0xd7ebc2]
    /lib/i386-linux-gnu/libc.so.6(+0x6f862)[0xd7f862]
    /lib/i386-linux-gnu/libc.so.6(cfree+0x6d)[0xd8294d]
    /usr/lib/i386-linux-gnu/libgfortran.so.3(+0xc27d9)[0x5397d9]
    /usr/lib/i386-linux-gnu/libgfortran.so.3(+0xc45c7)[0x53b5c7]
    /usr/lib/i386-linux-gnu/libgfortran.so.3(+0xc517c)[0x53c17c]
    /usr/lib/i386-linux-gnu/libgfortran.so.3(_gfortran_transfer_real+0x46)[0x52ec86]
    /usr/lib/i386-linux-gnu/libgfortran.so.3(_gfortran_transfer_real_write+0x2b)[0x52eccb]
    ./a.out[0x8048e0e]
    ./a.out[0x8048ee3]
    /lib/i386-linux-gnu/libc.so.6(__libc_start_main+0xf3)[0xd29113]
    ./a.out[0x8048761]
    ======= Memory map: ========
    00110000-00182000 r-xp 00000000 08:02 1055179 /usr/lib/i386-linux-gnu/libquadmath.so.0.0.0
    00182000-00183000 r--p 00071000 08:02 1055179 /usr/lib/i386-linux-gnu/libquadmath.so.0.0.0
    00183000-00184000 rw-p 00072000 08:02 1055179 /usr/lib/i386-linux-gnu/libquadmath.so.0.0.0
    00184000-001ac000 r-xp 00000000 08:02 263108 /lib/i386-linux-gnu/libm-2.13.so
    001ac000-001ad000 r--p 00028000 08:02 263108 /lib/i386-linux-gnu/libm-2.13.so
    001ad000-001ae000 rw-p 00029000 08:02 263108 /lib/i386-linux-gnu/libm-2.13.so
    0039b000-0039c000 r-xp 00000000 00:00 0 [vdso]
    00477000-00576000 r-xp 00000000 08:02 1055061 /usr/lib/i386-linux-gnu/libgfortran.so.3.0.0
    00576000-00577000 r--p 000fe000 08:02 1055061 /usr/lib/i386-linux-gnu/libgfortran.so.3.0.0
    00577000-00578000 rw-p 000ff000 08:02 1055061 /usr/lib/i386-linux-gnu/libgfortran.so.3.0.0
    00578000-00579000 rw-p 00000000 00:00 0
    006ed000-00709000 r-xp 00000000 08:02 263099 /lib/i386-linux-gnu/libgcc_s.so.1
    00709000-0070a000 r--p 0001b000 08:02 263099 /lib/i386-linux-gnu/libgcc_s.so.1
    0070a000-0070b000 rw-p 0001c000 08:02 263099 /lib/i386-linux-gnu/libgcc_s.so.1
    008ff000-0091d000 r-xp 00000000 08:02 263065 /lib/i386-linux-gnu/ld-2.13.so
    0091d000-0091e000 r--p 0001d000 08:02 263065 /lib/i386-linux-gnu/ld-2.13.so
    0091e000-0091f000 rw-p 0001e000 08:02 263065 /lib/i386-linux-gnu/ld-2.13.so
    00d10000-00e86000 r-xp 00000000 08:02 263078 /lib/i386-linux-gnu/libc-2.13.so
    00e86000-00e88000 r--p 00176000 08:02 263078 /lib/i386-linux-gnu/libc-2.13.so
    00e88000-00e89000 rw-p 00178000 08:02 263078 /lib/i386-linux-gnu/libc-2.13.so
    00e89000-00e8c000 rw-p 00000000 00:00 0
    08048000-0804a000 r-xp 00000000 08:02 919129 /home/bachtouti/Bureau/go/a.out
    0804a000-0804b000 r--p 00001000 08:02 919129 /home/bachtouti/Bureau/go/a.out
    0804b000-0804c000 rw-p 00002000 08:02 919129 /home/bachtouti/Bureau/go/a.out
    08b7d000-08b9e000 rw-p 00000000 00:00 0 [heap]
    b7600000-b7621000 rw-p 00000000 00:00 0
    b7621000-b7700000 ---p 00000000 00:00 0
    b7730000-b7732000 rw-p 00000000 00:00 0
    b7742000-b7744000 rw-p 00000000 00:00 0
    bf80e000-bf82f000 rw-p 00000000 00:00 0 [stack]
    Aborted
    bachtouti@bachtouti-Satellite-L350:~/Bureau/go$ gfortran go.f95
    bachtouti@bachtouti-Satellite-L350:~/Bureau/go$ ./a.out
    entrez alpha,lx,lt,deltax,deltat,tinit,tlimg,tlimd
    0.00001
    20
    10
    0.1
    1
    300
    350
    440
    *** glibc detected *** ./a.out: free(): invalid next size (fast): 0x08eb12c0 ***
    ======= Backtrace: =========

  8. #8
    Membre confirmé
    Profil pro
    Inscrit en
    Mars 2007
    Messages
    488
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2007
    Messages : 488
    Points : 593
    Points
    593
    Par défaut
    Bonjour,

    allocate (t(m,n))
    m=INT((lx/deltax))+1
    n=INT((lt/deltat))+1
    Ca te semble normal de d'abord allouer le tableau t(m,n) de taille m,n et ensuite de calculer les valeurs de m et n ?

    Je ne peux que te faire le conseil habituel: lis attentivement la doc de ton compilateur pour apprendre à utiliser les options de compilations utiles pour déceler les problèmes "classiques" (variables non ou mal initialisées, dépassements de tableaux, etc.).

    Bonne continuation.

  9. #9
    Candidat au Club
    Homme Profil pro
    Inscrit en
    Janvier 2012
    Messages
    7
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Algérie

    Informations professionnelles :
    Secteur : Enseignement

    Informations forums :
    Inscription : Janvier 2012
    Messages : 7
    Points : 3
    Points
    3
    Par défaut c'est vraiment important!
    bonjours monsieur
    je peut localiser qq part l'erreur
    je vraiment besoin de votre aide

    le nouveau c comme ca

    program heat
    implicit none
    integer::m,n
    integer:: i,j
    real::alpha,deltax,deltat,lx,lt,tinit,tlimg,tlimd,r
    !real, dimension(m,n) :: t
    real, dimension(:,, allocatable :: t

    print*, "entrez alpha,lx,lt,deltax,deltat,tinit,tlimg,tlimd"
    read*, alpha,lx,lt,deltax,deltat,tinit,tlimg,tlimd


    r=alpha*deltat/(deltax)**2
    if (r>0.5) then
    print*, "la condition de convergence ne pas fatisfaite"
    else

    allocate (t(m,n))
    m=INT((lx/deltax))+1
    n=INT((lt/deltat))+1


    do i=1,m
    t(i,1)=tinit
    end do

    do j=2,n
    t(1,j)=tlimg
    end do

    do j=2,n
    t(m,j)=tlimd
    end do

    !methode explicite de resolution
    do j=1,n
    do i=2,m-1 ! erreur q part ici
    t(i,j+1)=r*t(i-1,j)+(1-2*r)*t(i,j)+r*t(i+1,j)
    end do
    end do




    do j=1,n
    write(1,*) j, (t(i,j),i=1,m)
    end do
    deallocate (t)

    end if
    end program heat

    j 'ai essaye
    la compilation etait bien faite
    mais c ca

    Runtime error from program:c:\users\bachtouti\desktop\111111111111\freeformat15.exe
    Run-time Error
    *** Error 11, Array subscript(s) out-of-bounds

    main - in file freeformat15.f95 at line 38 [+0935]

  10. #10
    Modérateur

    Profil pro
    Inscrit en
    Août 2006
    Messages
    974
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Août 2006
    Messages : 974
    Points : 1 346
    Points
    1 346
    Par défaut
    Tu n'as toujours pas répondu à la question suivante :
    Citation Envoyé par Ehouarn Voir le message
    Ca te semble normal de d'abord allouer le tableau t(m,n) de taille m,n et ensuite de calculer les valeurs de m et n ?

Discussions similaires

  1. Equation de la chaleur 1D avec MATLAB
    Par pubis2luxe dans le forum Mathématiques
    Réponses: 0
    Dernier message: 07/06/2014, 23h30
  2. [Débutant] Equation de la chaleur / Image 1D 2D
    Par bilou_12 dans le forum Images
    Réponses: 4
    Dernier message: 26/03/2012, 23h04
  3. programme d'equation de la chaleur
    Par najoua01 dans le forum Débuter
    Réponses: 9
    Dernier message: 30/01/2011, 12h10
  4. Equation de la chaleur
    Par kawtar2 dans le forum Fortran
    Réponses: 9
    Dernier message: 10/03/2009, 19h41
  5. equation de la chaleur
    Par mirinda dans le forum Mathématiques
    Réponses: 5
    Dernier message: 25/06/2008, 12h04

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo