I am a PhD student in economics and making a mathematical model of some stuff in a subject of my interest.
While I was searching papers on Google Scholar, I found a PhD thesis written 5-6 years ago in my university, in which one of the chapters is somewhat very close to my stuff.
Just for an important detail, my idea is totally different and I think it is an interesting idea but the model is just slightly different from author's thesis and the solution method is very close. In particular, the model framework that author used is a very commonly used framework in the literature but accidentally my solution method is very close to the author's method.
For sure without doubt, I will give the exact reference with the chapter and state where my idea is different from author's idea.
My question is: is this a plagiarism? How can I avoid any plagiarism problems? Should I contact the author in order to invite him to be my co-author in this case?
Your situation is not in any way plagiarism, but rather a common and ordinary case of independent reinvention.
There is no need to have the other person as a co-author or anything like that: just cite their model as related prior work, explain how yours is similar and different, and learn from it so that you can do the best you can with your own work.