Challenge

Week 2 Air standard Cycle

LS DYNA – Python for Mechanical Engineers

By Enos Leslie

Mechanical Engineer

2nd October 2024


AIM

This project aims to write a code in Python to solve and plot an otto cycle and solve for its thermal efficiency.


PROCEDURE

The Otto cycle is an air-standard cycle, we will assume the gamma value to be 1.4. At the initial condition, we set the values of T1 and P1 as 400K and 101.325 kPa, respectively. The geometric parameters—stroke, diameter, connecting rod length, and crank start/end angles—are defined within the program. Based on these parameters, the clearance volume (v_c) and swept volume (v_s) are calculated. The remaining states are determined using the adiabatic process and the ideal gas law. Similarly, the thermal efficiency is computed using the corresponding formulas. To plot the pressure-volume (P-V) diagram, the plt.plot command from the matplotlib.pyplot module is used. For the compression phase, the crank angle ranges from 180 to 0 degrees, and for the expansion phase, it ranges from 0 to 180 degrees. We will iterate 30 times, creating an empty set to store the calculated values using the append command.


PYTHON CODE




RESULTS

Thermal efficiency is: 0.6298928275128466

62.9%


CONCLUSION


The p-v diagram above was successfully created and the thermal efficiency of the engine was found to be 62.9%

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.