# Harmonic Boundary Condition (noob Fortran question)

 Register Blogs Members List Search Today's Posts Mark Forums Read

 August 30, 2018, 18:08 Harmonic Boundary Condition (noob Fortran question) #1 New Member   Fredh Join Date: Dec 2014 Posts: 2 Rep Power: 0 Hey guys, I am trying to simulate a steady 2d temperature field for an assignment. I have constant prescribed temperatures on 3 edges of a rectangular mesh but one of them has a sine function that varies with height. I've been trying to code this for a while with no succes, if anyone could help me I would appreciate. Here's the bit of code I am having trouble with: !West Boundary if (i .eq. 2) then aw = 2*cond*dy/dx yy(j) = dy do while (j .lt. m2) T(2,j) = Tini*sin(pi*yy(j)/a) yy(j) = yy(j)+dy end do end if !test write(*,*)"T west = ",T(2,5) It always returns T west = 0.0000...

 August 30, 2018, 18:19 #2 Senior Member   Filippo Maria Denaro Join Date: Jul 2010 Posts: 6,388 Rep Power: 67 Tini is correctly prescribed? Then, let us start for example at j=2 yy(2) = dy do while .... T(2,2) = Tini*sin(pi*yy(2)/a) yy(2) = yy(2)+dy T(2,3) = Tini*sin(pi*yy(3)/a) yy(3) = yy(3)+dy ..... what about your yy update???

 August 31, 2018, 11:08 #3 Senior Member   Join Date: Jul 2009 Posts: 337 Rep Power: 17 My eyes may be getting old but it looks like you have i in the if test and j as the loop index. Are these supposed to be different? Where is the value of i set to get you into the if test block? Where is j incremented?

 September 2, 2018, 10:24 #4 New Member   Fredh Join Date: Dec 2014 Posts: 2 Rep Power: 0 I think I found the problem, I was trying to set the boundary conditions before the temperature field, gonna try to fix it, thanks!

 Tags code, fortran 90, loop, mesh