Pages

Monday, December 20, 2010

My first fluids problem solver using Fortran

With the mean dark days behind me (fall finals), I now have time to pluck at things for fun. I totally lost interest in MatLab and advancing the capabilities of the slider crank mechanism problem is on hold. I got my self a new toy C::B and since I've not been able to gather the motivation to learn C++ or start solving engineering problems in C, I decided to start playing around with Fortran. It seems to have a much cleaner syntax compared to C, at least for calculations (which is what Fortran is really meat for in the first place).

With AER316 behind me, I ran back to Frank M. White and goofed around. With a little help from a few lecture notes and the web, here's the result of what I've done. ;)


That's a screen shot of the code I wrote. I used VIM to get the screen shot as Code::Blocks - C::B has a somewhat bigger interface and all I intended to place here was the code. Compiled it with GFortran and it worked well. As I progress with Fortran, I might add more capabilities if I get a chance to do so.

Saturday, December 18, 2010

Settled for an Integerated Development Environment.

After a lot of digging I finally settled for an IDE. And the winner is Code::Blocks - C::B. I did quite a bit of reading and sampling. I'm somewhat new to using IDE's. Prior to today, I've been coding using vim without X window as well as compiling. Lets see how this goes. Wish me luck. Go Code::Blocks go C::B. ;)

Wednesday, December 1, 2010

Slider crank mechanism with Newton-Rapheson method

A = 1;
B = 2*LENGTH_AB*sin(ANGLE_ALPHA);
C = (((LENGTH_AB)^2 + 2*LENGTH_CD*LENGTH_AB*cos(ANGLE_ALPHA) + LENGTH_CD^2 - LENGTH_BC^2));
LENGTH_DA = (B + sqrt(B^2 - 4*C))/2;

A small part of the MatLab code I wrote while trying to implement a slider crank mechanism. This one was kinda tricky as the problem presented was somewhat restrictive.

The cylinder was oscillating on a translational path along the x axis above the crank. I only was given the angle at the crank source, its angular velocity, the magnitude of the arms and potential offset of the cylinder. After much digging, I decided to try this method as it allowed me write all distances in vector form. This way, I will be able to determine the maximum angle the crank end can go as it is somewhat dependent on the magnitude of the arms. I plan to add more features to this system later.

NOTE: The code chunk above is only for the positive roots. Negative roots was not needed for this problem. Might be once I start to expand the capabilities of this program.