Hi there. First of all, your question is wrong because buck converter does not work in bidirectional power flow, and also just boost converter does not work in bidirectional. I believe that you are looking for buck boost converter to get charging and discharging feature. As a result, I would like to refer you to this link (http://forum.hvdc.ca/890468/Chopper-b...
) and combining these model with each other leads you to achieve your goal.
Your model after combination becomes like this photo
I have attached a paper that will for sure help you.