A nanocomposite electrical generator composed of Zinc oxide nanowires (ZnO NWs) was modeled using continuum mechanics and Maxwell's equations. Axial loading was considered and the optimum aspect ratio of ZnO NWs for getting to maximum electric potential was calculated. The bonding between the ZnO NWs and the polymer matrix was considered to be perfect and the linear piezoelectric behavior was assumed. It was shown that the electric potential has maximum and minimum values of opposite signs at the extreme ends along the nanowire length. The maximum generated electric potential varies from 0.01717 for a NW with an aspect ratio of one to 0.61107 for a NW with an aspect ratio of thirty. The optimum aspect ratio of ZnO NW was defined as the difference between the maximum generated electric potential at which the difference becomes less than 1%, which results in an aspect ratio of 16. The results are a major step toward producing ZnO NWs for nanocomposite electrical generators with maximum performance.