Text this: Optimal Hierarchical Control for Smart Grid Inverters Using Stability Margin Evaluating Transient Voltage for Photovoltaic System