Slowing Down is the Key…..

slow down

Slowing down is the key to increased speed.

Past couple of months I was dabbing with fortran GUI and trying pgplot graphics library. I have produced gui’s in c, vb and then integrated them with fortran, but creating GUIs from fortran was new to me.

As the exploration began I took the fire aim adjust approach!! Dived deep into the tutorials and anything that I could lay my hands on.

Quickly from tutorials I graduated to actually creating my own little programs. This went on for a couple of months.

In the beginning I was sprinting as hard as possible. Learning, doing, getting stuck, reading and then doing again. The pace was fast.

But as I become comfortable, my approach shifted. I slowed.

I wrote a program and pondered how and what am I actually doing. This slowing down and pondering doubled my learning. It felt like I was learning at greater pace with this slowdown.

So the technique I want to advocate to anyone learning a new programming language, a new analysis tool or cad software, is to sprint in the first few weeks. Race and learn as much as you are able to handle. Dive deep and continue the pace as long as you are able to.

When exhaustion, sense of acheivement begins to creep in, slow down. Become deliberate in what you do? Question why and what you are doing?

I hope applying this method will help you as much as it has helped me.

What are your views, do let it out in the comments.

How to Create PGPLOT Fortran Programs With Intel Fortran Compiler ? An animated Journey…

How to create PGPLOT P\programs with Intel Compiler?

How to create PGPLOT programs with Intel Compiler?

How to create PGPLOT Fortran programs with Intel compiler is one of the popular post on this blog and every few days I get a request to share the powerpoint, so here’s the animated version of the powerpoint for quick reference..

Using PGPLOT, then you should visit and see these pages. Want the make file shown in the above animation, visit  How to use pgplot in windows with intel fortran. to download it!

Hermite Polynomials.

Hermite Polynomials are showing up in all most all the technical papers that I am reading these days.

Their constant appearance lead me to investigate them further. After a couple of hour of digging, I have this fortran module ready to get and evaluate hermite Polynomials.

The figure shows Pgplot output of these polynomials. Click the image to enlarge.

Here’s the fortran module to handle Hermite Polynomials.

On Wasting time and inefficiency

From the new rules blog

Wasting time and inefficiencies are the way to discovery. When Condé Nast’s editorial director Alexander Liberman was challenged on his inefficiencies in producing world-class magazines such The New Yorker, Vanity Fair, and Architectural Digest, he said it best: “I believe in waste. Waste is very important in creativity.”

Out of many things, inefficiencies have helped me learn java and pgplot at a faster rate.

Trying things, creating silly programs has produced so many wasteful programs, but each has sharpened the skills.

Animating Heart using pgplot with fortran

Here’s the code for the heart animation written in fortran, using pgplot and quickwin.

Not an optimized code but mashed quickly to get something up and running.

Find the story and code in action at the following post Did i miss the valentine’s day?

      MODULE DATAitem

      TYPE thedata
        REAL x0,y0,xf,yf,dx,dy,speed
        CHARACTER(len=1) schar
      END TYPE

      INTEGER,parameter :: isteps=15,iinum=2000
      INTEGER inum
      LOGICAL :: direction

      PROGRAM heart

! Animating heart.
! by sukhbinder
! date: 27th Feb 2012

      USE DATAitem
      USE IFqwin

      TYPE(qwinfo) :: winfo
      INTEGER(4)   :: RESULT

      INTEGER  :: pgopen,pgcurs
      REAL xr(iinum),yr(iinum)
      TYPE(thedata) alpa(iinum)
      CHARACTER*1 ch

      RESULT= setwsizeqq(qwin$framewindow,winfo)

      RESULT=aboutboxqq("Heart animation IN PGPLOT\rSukhbinder SINgh\rVersion 1.0\r15Feb2012"C)

      direction =.true.

      IF(pgopen('/w9') .LE. 0) STOP

      CALL pgenv(-2.0,2.0,-2.0,1.5,1,-2)

      DO iii=100,2000,200
         CALL INit
         CALL mydelay(500)
         CALL ani

      END DO

      CALL pgclos


      SUBROUTINE ani

       DO i=1,isteps
         CALL pgbbuf()

          CALL pgsci(0)

            CALL pgpt(inum,alpa%xf,alpa%yf,1)

          CALL pgsci(2)
          DO j=1,inum
            IF(direction) THEN

            END IF

          END DO
          CALL pgpt(inum,alpa%xf,alpa%yf,1)
          CALL mydelay(400)

         CALL pgebuf()
       END DO

       IF(direction) THEN
         direction = .FALSE.
         direction = .TRUE.
       END IF


      SUBROUTINE init

      REAL xxx(3)

      yr(1)=(cos(xr(1)))**0.5 * cos(200*xr(1)) + (abs(xr(1)))**0.5 -0.7 &
	  * (4.0 -xr(1) * xr(1))**0.01
      DO i=2,inum
       yr(i)=(cos(xr(i)))**0.5 * cos(200*xr(i)) +  (abs(xr(i)))**0.5 -0.7 &
	   * (4.0 -xr(i) * xr(i))**0.01
      END DO

       DO i=1,inum
         CALL RANDOM_NUMBER(xxx)
         xxx(1)=-20.0 + xxx(1)*40.0
         xxx(2)=-20.0 + xxx(2)*40.0

       END DO

        CALL pgsci(2)
       CALL pgpt(inum,alpa%xf,alpa%yf,1)


      SUBROUTINE mydelay(nnsec)
      INTEGER :: COUNT, count_rate, count_max,nnsec,icount

      CALL SYSTEM_CLOCK(count, count_rate, count_max)
      icount = count+nnsec
        CALL SYSTEM_CLOCK(count, count_rate, count_max)
        IF(count .GE. icount) EXIT

      END DO


Did I Miss Valentine’s Day?

Did I miss valentine’s day? Actually no. But was super busy at office. And at home busy with my daughter and a sport meet that i was help organizing.

Now the sports meet is over and yesterday i saw and completed this animation in fortran.

Actually i was lazy and used the code from previous”Heart In fortran” code and created this animation.

The video do not do justice, you need to download the exe and see it for yourself. Will post the source code little latter.

By the way. Happy Valentine’s Day.

Neutron Collisions, Stanislaw Ulam , Solitares and my Pgplot practice.

The year was 1946. Physicists at Los Alamos Scientific Lab were investigating radiation shielding and distance neutrons would travel in various materials. Despite having the data, the problem could not be solved with analytical calculations.

At the very same time, Stanislaw Ulam was convalescing from an illness and playing solitaires and thinking. His thoughts meandered around what are the chances that a Canfield solitaire laid out with 52 cards will come out successfully?

Stanislaw says “After spending a lot of time trying to estimate them by pure combinatorial calculations, I wondered whether a more practical method than “abstract thinking” might not be to lay it out say one hundred times and simply observe and count the number of successful plays. This was already possible to envisage with the beginning of the new era of fast computers, and I immediately thought of problems of neutron diffusion and other questions of mathematical physics, and more generally how to change processes described by certain differential equations into an equivalent form interpretable as a succession of random operations. Later, I described the idea to John von Neumann, and we began to plan actual calculations”

Thus the Monte Carlo Method was born.

Monte Carlo methods are a class of computational algorithms that rely on repeated random sampling to compute their results. These methods are most suited to calculation by a computer and tend to be used when it is infeasible to compute an exact result with a deterministic algorithm. Source wikipedia

If you read through the above Wikipedia article, it explains a method to estimate the value of Pi approximately using Monte Carlo Method. So here’s the Fortran program just doing that.

It uses PGPLOT as the graphics engine and you can see graphically see how the program estimates the value of Pi.

This slideshow requires JavaScript.

Really cool!! But not as cool as neutron collisions!

Download the program and Download the source