RE: engine needed
Those numbers you're using are the displacement in cubic inches. A "40" is actually a 0.40 cu in displacement and so on. If you're in Europe or other metric locations the conversion to CC's is quite common with a "40" being 7.5 CC.
What engine for what airplane? It's a matter of experience and desire for power versus ease of flying. Wing area and weight come into the picture. You can bypass all this stuff by looking up planes that are similar to what you have and select an engine that way. There just is no calculation that you do. For example I fly a 300 sq inch model with an 049 (0.049 cu in) which is totally usable for the type of lightweight contest model it is. Other folks would think nothing of putting on a 32 for that same size. But you have to realize that the mission profiles are WAY different.
And since you're working on a trainer (I gather) it's normal in that case to put a 25 or close to that on a 400 to 500 sq inch model of normal construction. A 40 would go on something up to 650 or so for the same performing TRAINER. Others may say otherwise but that's how I would size them. But then I'm a free flighter and seem to build lightly by nature. I've seen 500 sq in ARF's that can barely get off the ground with a 40 because they came out heavy. And they flew like it too.