In the present work, a single zone combustion model with detailed chemical kinetics is developed to study the effect of dimethyl ether (DME) concentration on the combustion of natural gas from second law point of view in a homogeneous charge compression ignition (HCCI) engine. The code can predict all exergy terms in the cylinder with crank angle during a closed cycle. The chemical kinetics mechanism includes 83 species and 360 reactions. Exergy analyses is employed for different DME concentration and initial charge temperature at constant natural gas (NG) concentration. The results show that when the excess air ratios of DME increases from 6.5 to 14.7 at a constant air ratio of NG = 7.1), exergy efficiency increases 30.2% and irreversibility decreases 15.4%. Also, an increase in initial temperature, decreases the irreversibility and increases the heat loss exergy.