RohanCFD's Blog

Happy Life, Happy Cfd

二维热传导计算程序

RohanCFD posted @ 2013年3月10日 11:22 in CFD , 5435 阅读

只适用于二维情况下的矩形,超级简单的程序,带的参数也少,是自己写的第一个程序~哈哈

初温为0,边界条件自己设定

 

        PROGRAM HEATTRANSFER_2D
        IMPLICIT NONE

        CHARACTER :: FILENAME*30,STEP*6
        INTEGER :: XMAX,YMAX,ZMAX,N,NMAX,STEPD
        INTEGER :: I,J,K,S(4)
        REAL :: DX,DY,DT,DT0,Kr,T0(1:4),A,B,T
        REAL,ALLOCATABLE :: X(:,:,:),Y(:,:,:),Z(:,:,:),TEMP(:,:,:)

        WRITE(*,*) "PLEASE INPUT FILENAME:"
        READ(*,*) FILENAME
        !----------------------------------------------------读取网格文件--------------------------------------------------------------------------
        OPEN(10,FILE=TRIM(FILENAME))       !Read Mesh File
        READ(10,*) XMAX,YMAX               !Get Mesh Size          
        ZMAX=1                             
        ALLOCATE(X(XMAX,YMAX,ZMAX),Y(XMAX,YMAX,ZMAX),Z(XMAX,YMAX,ZMAX))   !生成网格坐标存储空间
        ALLOCATE(TEMP(XMAX,YMAX,ZMAX))                                    !生成温度存储空间
        READ(10,*) (((X(I,J,K),I=1,XMAX),J=1,YMAX),K=1,ZMAX),(((Y(I,J,K),I=1,XMAX),J=1,YMAX),K=1,ZMAX),(((Z(I,J,K),I=1,XMAX),J=1,YMAX),K=1,ZMAX)
        CLOSE(10)
        !-----------------------------------------------------确定步长时间------------------------------------------------------------------------
        DX=(MAXVAL(X)-MINVAL(X))/XMAX
        DY=(MAXVAL(Y)-MINVAL(Y))/YMAX
        
        WRITE(*,*) 'Please input the rate of heat transfer k'
        READ(*,*) Kr
        DT0=(1/2.0/K)/(1/DX**2+1/DY**2)/2.0
		WRITE(*,*) 'Please input the step time, suggest it smaller than ',DT0
		READ(*,*) DT
		
		!------------------------------------------------------确定边界\初值条件-----------------------------------------------------------------------
		TEMP(1:XMAX,1:YMAX,1:ZMAX)=0
		!------------------确定边界条件类型------------------
		DO I=1,4
				WRITE(*,*) "Select Boundary Condition Type For"
				SELECT CASE(I)
				    CASE (1) 
				        WRITE(*,*) "Left side"
				    CASE (2)
				        WRITE(*,*) "Bottom"
				    CASE (3)
				        WRITE(*,*) "Right side"
				    CASE (4) 
				        WRITE(*,*) "Top"
				END SELECT
				WRITE(*,*) "1\Temperature"
				WRITE(*,*) "2\Rate of Temperatur Spread"
				READ(*,*) S(I)
		END DO
		!-----------------确定边界条件数值-------------------
		WRITE(*,*) "Please input the number for boundaries of left, bottom, right and up,use comma to seperate./The number should be wrote in 7 chracter and 3 float number(including comma)"
		READ(*,"(F7.2,','F7.3,',',F7.3,','F7.3)") T0(1:4)
		!----------------------------------------------------------------输入迭代次数\显示代数------------------------------------------------------------
		WRITE(*,*) 'Please input the number of steps'
		READ(*,*) NMAX
		WRITE(*,*) "Please input the number between two steps to show"
		READ(*,*) STEPD
		N=0
		T=0
100     N=N+1
        T=T+DT

		SELECT CASE(S(1))
		    CASE(1) 
		        TEMP(1,1:YMAX,1:ZMAX)=T0(1)
		    CASE(2) 
		        TEMP(1,1:YMAX,1:ZMAX)=(0-T0(1)*2*DX-TEMP(3,1:YMAX,1:ZMAX)+4*TEMP(2,1:YMAX,1:ZMAX))/3
        END SELECT
        SELECT CASE(S(2))
		    CASE(1) 
		        TEMP(1:XMAX,1,1:ZMAX)=T0(2)
		    CASE(2) 
		        TEMP(1:XMAX,1,1:ZMAX)=(0-T0(2)*2*DY-TEMP(1:XMAX,3,1:ZMAX)+4*TEMP(1:XMAX,2,1:ZMAX))/3
        END SELECT
        SELECT CASE(S(3))
		    CASE(1) 
		        TEMP(XMAX,1:YMAX,1:ZMAX)=T0(3)
		    CASE(2) 
		        TEMP(XMAX,1:YMAX,1:ZMAX)=(0-T0(3)*2*DX-TEMP(XMAX-2,1:YMAX,1:ZMAX)+4*TEMP(XMAX-1,1:YMAX,1:ZMAX))/3
        END SELECT
        SELECT CASE(S(4))
		    CASE(1) 
		        TEMP(1:XMAX,YMAX,1:ZMAX)=T0(4)
		    CASE(2) 
		        TEMP(1:XMAX,YMAX,1:ZMAX)=(0-T0(1)*2*DY-TEMP(1:XMAX,YMAX-2,1:ZMAX)+4*TEMP(1:XMAX,YMAX-3,1:ZMAX))/3
        END SELECT

        !-----------------------------------------------------二阶中心差分格式显式推进计算---------------------------------------------------------------------------
       	A=Kr*DT/DX**2
		B=Kr*DT/DY**2
		K=1
		XDO:DO I=2,XMAX-1
			YDO:DO J=2,YMAX-1
				TEMP(I,J,K)=A*(TEMP(I+1,J,K)+TEMP(I-1,J,K))+B*(TEMP(I,J+1,K)+TEMP(I,J-1,K))+(1-2*(A+B))*TEMP(I,J,K)
			END DO YDO
		END DO XDO
        !------------------------------------------------------收敛之判断-----------------------------------------------------------------------------------
        IF (MOD(N,STEPD) == 0) THEN
			WRITE(STEP,"(I6)") N
			OPEN (1,FILE='OUTPUT'//STEP//'_'//TRIM(FILENAME))
			WRITE(1,*) 'VARIABLES=','"X","Y","T"'
			WRITE(1,*) 'ZONE,I=',XMAX,',J=',YMAX,',F=POINT'
			DO I=1,XMAX
				DO J=1,YMAX
					WRITE(1,*) X(I,J,K),Y(I,J,K),TEMP(I,J,K)
				END DO
			END DO
			CLOSE(1)
		ENDIF
		
        WRITE(6,*) 'TIME=',T,',TEMPERATURE=',TEMP(XMAX/2,YMAX/2,K)
		IF(N < NMAX)  GOTO 100
		IF(N == NMAX) GOTO 101

101		WRITE(*,*) "THE COMPUTATION IS OVER!"
        
        WRITE(STEP,'(I6)') NMAX
        OPEN (2,FILE='OUTPUT'//STEP//'_'//TRIM(FILENAME))
        WRITE(2,*) 'VARIABLES=','"X","Y","T"'
        WRITE(2,*) 'ZONE,I=',XMAX,',J=',YMAX,',F=POINT'
        DO I=1,XMAX
            DO J=1,YMAX
            	WRITE(2,*) X(I,J,K),Y(I,J,K),TEMP(I,J,K)
            END DO
        END DO
        CLOSE(2)
        

        STOP
        END PROGRAM
Avatar_small
Anonymous 说:
2020年11月28日 23:55

it's really nice and meanful. it's really cool blog. Linking is very useful thing.you have really helped lots of people who visit blog and provide them usefull information. USD Moneta

Avatar_small
Anonymous 说:
2020年12月01日 22:40

This is very useful, although it will be important to help simply click that web page link: xrp to idr

Avatar_small
Anonymous 说:
2020年12月03日 02:43

I invite you to the page where you can read       with interesting information on similar topics. sa tech news

Avatar_small
Anonymous 说:
2020年12月03日 02:49

I can give you the address       Here you will learn how to do it correctly. Read and write something good. เครดิตฟรี บาคาร่า

Avatar_small
Anonymous 说:
2020年12月03日 02:58

You possess lifted an essential offspring..Blesss for using..I would want to study better latest transactions from this blog..preserve posting.. all bet ptgame24

Avatar_small
Anonymous 说:
2020年12月10日 05:15

In this particular article, you will see a summary, satisfy browse this post. Best Plastic Container Set for Kitchen

Avatar_small
Anonymous 说:
2020年12月12日 01:44

These websites are really needed, you can learn a lot.  rent a car beograd

Avatar_small
Anonymous 说:
2020年12月12日 01:48

I should assert barely that its astounding! The blog is informational also always fabricate amazing entitys. гидра сайт

Avatar_small
Anonymous 说:
2020年12月12日 01:52

Profit primarily prime quality items -- you can understand them all within: good night wallpaper

Avatar_small
Anonymous 说:
2020年12月12日 19:51

So it is interesting and very good written and see what they think about other people.  chansons albanaises

Avatar_small
Anonymous 说:
2020年12月15日 19:28

I should say only that its awesome! The blog is informational and always produce amazing things. wall filler in sri lanka

Avatar_small
Anonymous 说:
2020年12月16日 17:43

Can nicely write on similar topics! Welcome to      here you'll find out how it should look. best-laptop-for-streaming-netflix

Avatar_small
Anonymous 说:
2020年12月16日 17:49

On this page you can read       my interests, write something special. what is a keto diet

Avatar_small
Anonymous 说:
2020年12月16日 20:02

The Florence Residences 悦湖苑 is a new launch projected situated along Hougang Ave 2. It encompasses a total of 1410 units ranging from 1 to 5 bedrooms. The Florence Residences 悦湖苑 is situated in between of Hougang and Kovan giving it access to both MRT stations which owners will be able to enjoy immediately. It also features largely a north south facing orientation which is suitable for Singapore’s weather. Owners will also find themselves spoilt for choice in terms of amenities such as Hougang Swimming Complex and Sports Hall as well as Hougang Mall, Heartland Mall, Kovan Market and Hawker. Renowned schools of 1KM namely Holy Innocents’ Primary School, Montfort Junior School and Xinmin Primary School. The Florence Residences 悦湖苑 has been one of the fastest moving project due to its affordability. The Florence Residences Balance Unit

Avatar_small
Anonymous 说:
2020年12月16日 20:07

Parc Central Residences is located at mature estate Tampines along Tampines Street 86. The new Tampines Executive Condominium consist an approximate total of 700 units. It features a central park living in the east, football field sized expanse, dive in 80m pool. Parc Central Residences is near 3 Ready MRT stations around the Tampines Regional Centre. Various shopping malls and easily accessible amenities can be in the proximity of Parc Central Residences such as IKEA, Giant Supermarket and many more. Owners of Parc Central Residences will find various renowned schools nearby such as St Hilda Primary School and Poi Ching Primary School. Parc Central Residences Floorplan

Avatar_small
Anonymous 说:
2020年12月16日 20:12

Treasure At Tampines is a new mega launch property located in a matured town at 1 to 57 Tampines Lane. The new Condominium in Tampines constitutes a total of 2203 units with different layouts option of 1 to 5 bedrooms.Treasure At Tampines is situated at a golden location as many shopping facilities and amenities can readily be found within the minutes drive from Treasure At Tampines such as Tampines Mall, Century Square, Tampines 1, newly open Our Tampines Hub and more. Residents that bought Treasure At Tampines Condo will find a few renowned schools within such as St Hilda’s Primary, St Hilda’s Secondary School and Yumin Primary School.Treasure At Tampines Balance Unit

Avatar_small
Anonymous 说:
2020年12月16日 20:16

Penrose is a new launch property based at 20 Sims Drive. The new Aljunied Condo constitutes a total of 566 units ranging from 1 to 4 bedroom layouts. Penrose is located at a centralized location, within a mere 500 metres walk to Aljunied MRT. Several shopping facilities and amenities can readily be found 1 MRT stop away from Penrose such as PayaLebar Quarter, PayaLebar Square, SingPost Centre and more. Future Residents of Penrose Condo will find several good schools within such as Geylang Methodist School (Secondary) and Geylang Methodist School (Primary). Penrose is within close proximity to international schools  such as James Cook University and Nexus International School. It is also less than 15 minutes drive to Central Business District (CBD) Orchard Shopping Belt Penrose Balance Unit

Avatar_small
Anonymous 说:
2020年12月17日 22:40

Tante lenzuola matrimoniali per il tuo letto. Scopri la gamma e i colori delle più belle lenzuola per te. Acquista online e risparmia già oggi stesso. Lenzuola matrimoniali in cotone e lenzuola matrimoniali in microfibra ideali per il tuo letto e la tua camera da letto. ti aspettiamo sul nostro e-commerce www.shopcentroscampoli.com. Buona spesa e arrivederci a presto.

Avatar_small
Anonymous 说:
2020年12月17日 22:44

There is so much in this article that I would never have thought of on my own. Your content gives readers things to think about in an interesting way. Order Tapentadol 100MG

Avatar_small
Anonymous 说:
2020年12月17日 22:51

During this website, you will see this shape, i highly recommend you learn this review. Rent a car

Avatar_small
Anonymous 说:
2020年12月17日 22:56

I am interested in such topics so I will address       page where it is cool described. الزمالك

Avatar_small
Anonymous 说:
2020年12月17日 23:03

Great info! I recently came across your blog and have been reading along. I thought I would leave my first comment. I don’t know what to say except that I have. โจ๊กเกอร์123

Avatar_small
Anonymous 说:
2020年12月17日 23:05

For true fans of this thread I will address      is a free online!สมัครบาคาร่าออนไลน์

Avatar_small
Anonymous 说:
2020年12月22日 22:43

Excellent read, Positive site, where did u come up with the information on this posting?I have read a few of the articles on your website now, and I really like your style. Thanks a million and please keep up the effective work. metformin perte de poids

Avatar_small
Anonymous 说:
2020年12月23日 00:51

Cool you inscribe, the info is really salubrious further fascinating, I'll give you a connect to my scene.  Illustrated novel

Avatar_small
Anonymous 说:
2020年12月23日 00:55

I am interested in such topics so I will address       page where it is cool described. thiết kế website giá rẻ tại đà nẵng

Avatar_small
Anonymous 说:
2020年12月23日 00:59

Great info! I recently came across your blog and have been reading along. I thought I would leave my first comment. I don’t know what to say except that I have. สมัครสล็อตxo

Avatar_small
Anonymous 说:
2020年12月23日 01:04

I personally use them exclusively high-quality elements : you will notice these folks during: panic button for office

Avatar_small
Anonymous 说:
2020年12月23日 22:01

I am always searching online for storys that can accommodate me. There is obviously a multiple to understand about this. I feel you made few salubrious points in Attributes moreover. Detain busy, awesome career! basic differences

Avatar_small
Anonymous 说:
2020年12月24日 16:01

In this article understand the most important thing, the item will give you a keyword rich link a great useful website page:çeviri bürosu

Avatar_small
Anonymous 说:
2020年12月24日 16:02

I just thought it may be an idea to post incase anyone else was having problems researching but I am a little unsure if I am allowed to put names and addresses on here. Turkey dental implants

Avatar_small
Anonymous 说:
2020年12月29日 22:13

Very good topic, similar texts are       I do not know if they are as good as your work out. freight broker

Avatar_small
Anonymous 说:
2020年12月29日 22:16

This is very useful, although it will be important to help simply click that web page link: Empleo de Chofer para Uber en la Cdmx y en el Edomex

Avatar_small
Anonymous 说:
2021年1月11日 19:08

I wrote about a similar issue, I give you the link to my site. kurye

Avatar_small
Anonymous 说:
2021年1月14日 17:31

It is rather very good, nevertheless glance at the data with this handle. Investmentmakler Renchen

Avatar_small
Anonymous 说:
2021年1月14日 22:18

Very good topic, similar texts are       I do not know if they are as good as your work out. تطبيقات التجسس للأندرويد

Avatar_small
Anonymous 说:
2021年1月16日 20:29

I invite you to the page where you can read       with interesting information on similar topics. delikli sac

Avatar_small
Anonymous 说:
2021年1月16日 20:34

The most interesting text on this interesting topic that can be found on the net ...  hasta yataklarý

Avatar_small
Anonymous 说:
2021年1月16日 20:34

The most interesting text on this interesting topic that can be found on the net ...  hasta yataklarý

Avatar_small
Anonymous 说:
2021年1月25日 05:03

I am interested in such topics so I will address       page where it is cool described. Buy Cole Hauser Jacket

Avatar_small
Anonymous 说:
2021年1月25日 05:09

Acknowledges for penmanship such a worthy column, I stumbled beside your blog besides predict a handful advise. I want your tone of manuscript... valorant


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter