Amrita Pati
Ansys Employee

Hi Ashish, 

I used your code with cen_w = 1280 nm and w_span = 0 nm (not sure what you used for this field), I do not see any issue with the created dipole source. Here's a screenshot of the Frequency/Wavelength tab of the Dipole Source:

Would you be able to share a screenshot of yours?

I also ran the simulation (just a dipole in air) and checked the monitor results, in the results, the wavelength is also 1280 nm as you can see below:

You can find sample optimzation script here: Creating optimization tasks using a script

Regards,
Amrita