how to calculate the size of cable for 40kw motor

you need the current requirements for that motor, then, use your cable charts to see what cable is safe for that current.