Thursday, October 2, 2014

How To Plot Residuals in OpenFOAM

A sample script.


foamLog log.simpleFoam >/dev/null

gnuplot -persist > /dev/null 2>&1 << EOF
        set logscale y
        set title "Residual vs. Iteration"
        set xlabel "Iteration"
        set ylabel "Residual"
        plot "logs/Ux_0" with lines,\
                "logs/p_0" with lines

The video:

Friday, July 11, 2014

English Measurement Rounding Tool, Version 2

The input text field is the raw measurement to be rounded.
The dropdown menus are to select the precision of the rounding.
The answers are the rounded measurement, and the difference from the raw measurement.

Tuesday, July 8, 2014

Making a Two-Stroke Engine Turn the Opposite Direction

I have been trying to couple two TR-111 engines together symmetrically, and to do that one of them has to turn the opposite direction of the other, in order for both of them to turn the same direction on the coupled shaft. The convention for 2 stroke engines is counter-clockwise, looking from the "front" (looking at it such that the propeller / driven device is closest to you).

Thus I started looking into ways to make the engine go clockwise. My engine uses a CDI electronic ignition. The only information this requires from the engine is a Hall effect sensor signal. The Hall effect sensor is very visible and accessible. To make the sparks turn on correctly for clockwise motion, I just have to relocate the Hall effect sensor to its mirror-image location, where the mirror line is the piston center line.

The next part I would not have guessed on my own but am doing based on the findings of one forum discussion:

Within the forum there is some disagreement about what is necessary and what is not, but only one person has actually successfully reversed an engine. So I believe that person and will follow his procedure, which is to relocate the cylinder and piston 180 degrees. This way the engine is running exactly as it would in the normal counter-clockwise configuration.

One might ask why this is necessary, since the piston only moves up and down, and should not know anything about the rotation direction. However, the piston actually is affected by the rotation direction because the connecting pin to the crankshaft is angled with respect to the piston center line, so a side force is transmitted to the piston, which is then transmitted to the cylinder walls. The reason this is important is that the exhaust and intake ports are on the sides which receive the transmitted connecting pin side force. The ports are geometrically different, and therefore are designed to withstand different loads. Also the piston shape may be asymmetrically designed for the exhaust and intake sides. There are probably other reasons that the 180-degree relocation may be necessary that I do not know currently.

First unscrew the 4 bolts attaching the cylinder to the crankcase. Remove and replace them later in an x-pattern so that the tensions are better balanced.

Once the screws are removed, the cylinder is still stuck on quite tight. There is no glue on these gaskets between the cylinder and head, it is just that the gasket material bonds with the metal under the high pressure of the attachments screws. I had a bit of trouble figuring out how to remove the cylinder, as there is no space to allow for a wooden piece and hammer to nudge it out, as I have seen commonly done on various hobbyist forums. Looking inside the exhaust port however, you can see 2 divots on the other opposing cylinder wall. I lowered the piston, inserted 2 wooden dowels and turned the output shaft to raise the piston. This way, the cylinder came off very easily. If it still is too hard, you can try tapping the cylinder lightly using a rubber mallet with a piece of wood in between to try to loosen the gasket bond.

In removing the cylinders, the gaskets will probably rip to some degree. Both of mine ripped in one corner. I do not think it is good to reuse the gaskets, so you should buy replacement if you can. You can also buy gasket sheet at a local auto store and cut out a replacement, which is what I did.

The following are pictures of inside the cylinder. The loop-scavenged intake ports, boost ports, and exhaust ports can be seen.

The following are pictures of the piston. The exhaust side of the piston skirt is solid, while the opposite side has windows that correspond to the boost ports.

The following pictures show the connecting rod and the piston.

Looking inside the crankcase, I saw that a NSK 6203DU ball bearing sits in the housing that goes out to the propeller shaft. Here is a picture of the crankshaft and connecting rod.

Turning the piston 180 degrees is pretty straightforward. Two internal retaining rings, which can be removed with pliers, hold the assembly together. After the rings are removed, the connecting shaft can be removed, and the piston and connecting rod comes apart.

A needle bearing supports the connecting rod on the piston shaft.

The following picture shows a circular metal piece that keeps the piston ring ends at one position on the piston circumference.

After assembling the piston 180 degrees, put the internal retaining rings back on, and slide the cylinder back on 180 degrees from its original position. Before tightening the cylinder with bolts, slide the piston a few times to make sure it aligns freely.

So after these things are done, the engine should be able to run in the reverse direction. I have not run it yet, but I will update this post with any developments.

Saturday, July 5, 2014

Keyed Shaft Power Design Calculator

Because keyed shafts have rather sharp geometrical features, a significant stress concentration factor should be assumed when considering the results of this calculator.

Shaft diameter:
Key width:
Key height:
Key length:


External Shear Force:
External Tensile Force:

Monday, June 2, 2014

Pulley Belt Tension Calculator

This JavaScript calculator computes required belt tension for belt-driven pulley power transmission systems.

(Drawn to scale)
Drawing Scale Factor:
Small Diameter (in):
Large Diameter (in):
Center Distance (in):
Power (W):
Small Pulley Rotational Speed (rad/s):
Effective Friction Coefficient:

Thursday, May 15, 2014

English Measurement Rounding Tool

This simple calculator takes a measurement and rounds it to nearest standard English units.

I have used this when building my CAD designs. My designs in CAD have arbitrary, messy measurements (i.e. 1.734854" vs. 1 3/4"), and in order to measure and mark my raw materials I need to convert it to standard English units. I use this calculator for the conversion, and to determine whether the rounding is sufficiently accurate. My rule of thumb is to keep the difference between the exact and rounded measurements less than 10 thousandths of an inch. Depending on the precision requirements, more or less difference can be tolerated.


Rounded Measurement:

Saturday, May 10, 2014

Potential Flow Playground: Puff

Here is a little JavaScript program I wrote that allows one to play with potential flow by inserting sources in a wind tunnel. Potential flow is an idealized flow characterized by irrotationality. The particular form used here has the added characterizations of being inviscid and incompressible, and satisfies Laplace's Equation for a velocity 'potential':
The velocities are recovered by:
Second-order-accurate finite differencing schemes are used to recover the velocities.

I will continuously be working on this, so this is by no means the final version. Currently I aim to bring the following:
-Making it into a game

It is colored by potential. Click on it!

Discrete Resolution:

Pixel Dimensions:

Specifications of the Turnigy TR-111

I recently bought two 11.5 HP gas engines from Hobby King. They are made by Turnigy and have the designation TR-111.

Turnigy TR-111 111cc Twin Cylinder Gas Engine 11.5HP

Surprisingly, there is no way to get any information other than on the product page. There is not even a mention of it on the Turnigy website. So, here I post information that I have gleaned from inspecting the engine myself. I planned to use these engines together to the power the same drive shaft to get about 23 HP. I picked the TR-111 engine because they were relatively cheap, lightweight (NW of 2.5 kg each), and satisfied my power target of over 20 HP.

To see it in action, check out the video from 'redsjcman' (who also has a review on the HobbyKing product page):

I do not have a video of my own yet, but hopefully I will soon.

Now, let us move on to the specifications.

First, the general specifications listed on the box:

BORE AND STROKE: 45 mm * 35 mm * 2
IGNITION: Electronic Auto Advance Ignition
PROPELLER: 26*12 27*10
SPEED RANGE: 1400 PPM - 7000 RPM
OIL: 25-40: 1 MIX (the octane number should be 93 or higher : lubrication Type of 2-cycle oil)
NW: 2.5 kg

I made measurements using this dial caliper from Harbor Freight. I use three significant digits.

ID = Inside Diameter
OD = Outside Diameter


4 x (Standoff Spacer, Bolt and Washer)

Standoff Spacer Dimensions:
-0.789" (20.0 mm) height (distance parallel to axis of symmetry)
-0.615" (15.6 mm) small OD
-0.782" (19.9 mm) large OD
-0.236" (5.99 mm) bore
Bolt Dimensions:
-0.188" (4.78 mm) unthreaded diameter
-0.328" (8.33 mm) head diameter
-0.161" (4.09 mm) minimum hex socket diameter (for 4 mm Allen / Hex key)
Washer Dimensions:
-0.205" (5.21 mm) ID
-0.471" (12.0 mm) OD
-0.041" (1.04 mm) thickness

2 x (Muffler, Gasket, and Pair of Bolts):

Muffler Dimensions:
-1.956" (49.7 mm) can diameter
-4.046" (103 mm) can length
-0.984" (25.0 mm) chimney diameter
-0.045" (1.143 mm) chimney thickness
-~3.75" (95.3 mm) chimney length
-0.384" (9.75 mm) hex key passage hole diameter
-0.591" (15.0 mm) mount rectangle height
-1.03" (26.2 mm) mount rectangle width
-0.222" (5.64 mm) mount bolt hole diameter
Bolt Dimensions:
-0.192" (4.88 mm) threaded diameter
-0.330" (8.38 mm) head diameter
-0.160" (4.06 mm) minimum hex socket diameter
Gasket Dimensions:
-0.864" (21.9 mm) overall height
-2.04" (51.8 mm) overall width


Overall Dimensions (stripped down;unequipped with mounting hardware, ignition system, etc.):
(Please note these dimensions were not taken with a caliper, but with a ruler)
-6 11/64" length (excluding small shaft)
-10 5/32" width
-6 3/4" height

Engine Mounting Plate Dimensions:
-2.519" minimum distance between holes on shorter side.
-3.049" maximum distance between holes on shorter side.
By taking the average of the last two measurements, we can infer the hole center distance.
-2.784" (70.7 mm) center distance between holes on shorter side.
-3.435" maximum distance between holes on longer side.
-2.905" minimum distance between holes on longer side.
By taking the average of the last two measurements, we can infer the hole center distance.
-3.17" (80.5 mm) center distance between holes on the longer side.

Engine Small Shaft Dimensions:
-0.391" (9.93 mm) diameter
-1.571" (39.9 mm) length
-0.173" (4.39 mm) threaded hole inner diameter

Propeller Mounting Hardware:
6 x (Bolt, Washer, Split Lock Washer)

Bolt Dimensions:
-0.191" (4.85 mm) unthreaded diameter
-0.325" (8.26 mm) head diameter
-0.162" (4.11 mm) hex socket minimum diameter
Split Lock Washer Dimensions:
-0.217" (5.51 mm) ID
-0.324" (8.23 mm) OD
-0.053" (1.35 mm) thickness
Washer Dimensions:
-0.206" (5.23 mm) ID
-0.393" (9.98 mm) OD
-0.019" (0.483 mm) thickness
Cap Dimensions:
-1.676" (42.6 mm) OD
-0.398" (10.1 mm) bore
-0.153" (3.89 mm) thickness
-0.206" (5.23 mm) bolt hole diameter
-0.919" inner bolt circle diameter
-1.328" outer bolt circle diameter
From the average of the previous two, the bolt circle diameter can be inferred.
-1.1235" (28.5 mm) bolt circle diameter

From installed mounting spacer to shaft tip, the total length of the engine would be about 8.53".

Ignition System:

Text on the metal box:
CDI Rcexl
Automatic advancing angle ignition
for gas engines      Model:A-02
Voltage-Range: DC 4.8V/8.4V
Temperature Range: -40 degrees C / +60 degrees C

If you have any suggestions or requests, make a comment below.