Application of Python Coding in Mechanical Problems

Application of Python Coding in Mechanical Problems



This equation is known as the ideal gas law.

An ideal gas is defined as a hypothetical gaseous substance whose behavior is independent of attractive and repulsive forces and can be completely described by the ideal gas law. In reality, there is no such thing as an ideal gas, but an ideal gas is a useful conceptual model that allows us to understand how gases respond to changing conditions. As we shall see, under many conditions, most real gases exhibit behavior that closely approximates that of an ideal gas. The ideal gas law can therefore be used to predict the behavior of real gases under most conditions. The ideal gas law does not work well at very low temperatures or very high pressures, where deviations from ideal behavior are most commonly observed.

Significant deviations from ideal gas behavior commonly occur at low temperatures and very high pressures.

Before we can use the ideal gas law, however, we need to know the value of the gas constant R. Its form depends on the units used for the other quantities in the expression. If V is expressed in liters (L), P in atmospheres (atm), T in kelvins (K), and n in moles (mol), then

           R=0.08206 L⋅atm/K⋅mol

Because the product PV has the units of energy, R can also have units of J/(K•mol):

R=8.3145 J/K⋅mol


Sample Question :

2.035 g H2 produces a pressure of 1.015 atm in a 5.00 L container at -211.76 °C. What will the pressure( in atm)have to be if an additional 2.099 g H2 is added to the container and the temperature increases to -183.451 degrees Celsius?

Initial pressure (p1) =1.015atm  Final Pressure(p2)=?

Initial Temperature ( t1)=-211.76 degrees Celsius

Final temperature ( t2)=-183.451 degrees Celsius

m1=2.035g  m2=4.134g


A body is said to be in equilibrium if it continues its state of rest or its state of uniform motion.

Equilibrium can be categorized in two ways:

1) Static equilibrium: If a body is at rest and remains at rest, then the equilibrium is said to be static equilibrium.

Mathematically, if the sum of all the linear forces acting on the body is zero then the body is said to be in static equilibrium. This means that all the forces cancel out one another and the net result is zero.

2) Dynamic equilibrium: If a body is initially moving with some velocity and it continues its motion rectilinearly with the same velocity, or if the body is rotating with some initial angular velocity and the angular velocity remains constant, then the body is said to be in dynamic equilibrium.

Mathematically, if the sum of torque forces acting on the body is zero then the body is in dynamic equilibrium. Torque is the cross product of force being applied to the body and the perpendicular distance of the force from the axis of the body.



When a stretching force (tensile force) is applied to an object, it will extend. We can draw its force-extension graph to show how it will extend. Note: that this graph is true only for the object for which it was experimentally obtained. We cannot use it to deduce the behavior of another object even if it is made of the same material. This is because the extension of an object is not only dependent on the material but also on other factors like dimensions of the object (e.g. length, thickness, etc.) It is therefore more useful to find out about the characteristic extension property of the material itself. This can be done if we draw a graph in which deformation is independent of the dimensions of the object under test. This kind of graph is called the stress-strain curve.


Stress is defined as the force per unit area of a material.

i.e. Stress = force / cross sectional area:


σ = stress,

F = force applied, and

A= cross sectional area of the object.

Units of s: Nm-2 or Pa.


The strain is defined as an extension per unit length.

Strain = extension / original length


ε = strain,

lo = the original length

e = extension = (l-lo), and

l = stretched length

Strain has no units because it is a ratio of lengths.

We can use the above definitions of stress and strain for forces causing tension or compression.

If we apply tensile force we have tensile stress and tensile strain

If we apply compressive force we have compressive stress and compressive strain.

A useful tip: In calculations stress expressed in Pa is usually a very large number and strain is usually a very small number. If it comes out much different then, you've done it wrong!

Young Modulus

Instead of drawing a force-extension graph, if you plot stress against strain for an object showing (linear) elastic behavior, you get a straight line.

This is because stress is proportional to strain. The gradient of the straight-line graph is Young's modulus, E

E is constant and does not change for a given material. It in fact represents the 'stiffness' property of the material. Values of the young modulus of different materials are often listed in the form of a table in reference books so scientists and engineers can look them up.

Units of the Young modulus E: Nm-2 or Pa.

Note: The value of E in Pa can turn out to be a very large number. Therefore some times the value of E may be given MNm-2.


CODE 4: THERMODYNAMICS (Solving a diesel cycle) 

Diesel engine, any internal-combustion engine in which air is compressed to a sufficiently high temperature to ignite diesel fuel injected into the cylinder, where combustion and expansion actuate a piston. It converts the chemical energy stored in the fuel into mechanical energy, which can be used to power freight trucks, large tractors, locomotives, and marine vessels. A limited number of automobiles also are diesel-powered, as are some electric-power generator sets.
Diesel engine equipped with a precombustion chamber.

( )


Refer to the above link for the question and answer with explanation.)


Why can you bend a paper clip into any shape you want? Why does a glass pane break? The material properties of the paper clip and the glass pane are different. One way to visualize the difference in the material properties is a stress-strain curve.

A stress-strain curve is a graphical representation of the behavior of a material when it's subjected to a load or force. The two characteristics that are plotted are stress on the y-axis and strain on the x-axis. Stress is the ratio of the load or force to the cross-sectional area of the material to which the load is applied. The standard units of measure for stress are pounds per square inch or Newtons per square meter squared.

Strain, on the other hand, is a measure of the deformation of the material as a result of the force applied. Deformation is a change in the shape or form of the material. For example, a person standing on the end of a diving board causes it to deform or bend as a result of the weight or the force. There is no unit of measure for strain since it's a ratio of the deformation over the initial length. If for example, the strain measured is 0.05, this means that there are 0.05 inches of deformation for every inch of length.

Materials fall into two basic categories: brittle materials and ductile materials. Brittle materials, like glass, will break or fracture without bending when a large enough force is applied. Ductile materials, like steel or aluminum, will bend when a force is applied. If the force is large enough, the material will permanently deform and not return to its original shape. Let's look at a few typical stress-strain curves.



**Theory for this is same as that of CODE 3: STRENGTH OF MATERIALS

- Devyani Biswas