I am designing a bi-directional buck-boost converter for battery charger,to keep the power factor unity. I need a constant input power (i.e, if current is minimum the voltage will max & vice versa) . you can see in fig2 the current is max when voltage is max,how to keep input power constant for bi-directional buck-boost converter using cosine pwm?

No it's not. Power Factor of a circuit has very little effect on overall system efficiency. Typically fractions of a percent at best in an application like yours.

Especially so when compared to the unavoidable losses that are present in charging a battery which are measured in multiple 10's of percents.

Click to expand...

I am building this charging circuit for 72v ,10amps battery ,
when i simulate this circuit in matlab, the 2nd harmonics content is very high in source current.
is there any method to eliminate 2nd harmonics ?

The harmonic content arises from the use of waveforms with sharp edges and corners. There is presumably a reason for doing this; but where do you want to eliminate this harmonic content? I suggest you try a different method.