you don't give any of the terrain or weather / wind conditions, or the riding style, weight, etc., so i can only give you rough guesstimates for power requirements. the below will be based on completely flat roads with zero slopes or hills, and absolutely no wind of any kind, ever, and assuming you don't care how long it takes to reach your cruising speed (too low a power and too high a weight and it could take a mile to get up to speed). you'll have to give *complete* info to get better numbers. or have a play with the simulator (or other online tools) to figure out what you're after.
so...:
40mph on an unfaired two wheeler is likely to take at least
here's a simulation of something vaguely similar (as far as the simulator is concerned for numbers) to your proposed setup.
https://www.ebikes.ca/tools/simulator.html?motor=MX4504&batt=cust_88_0.2_25&cont=C40&hp=0&mass=272&frame=fat&axis=mph
this uses an unsuitable ebike hub motor (mxus 4504), as it was handy in the list and i have one so i am familiar with it; you'd want to be using a heftier motor (qsmotors has a number of them that would probably work, but don't know which might be needed until you provide complete info as noted above). this particular motor overheats easily at these power levels, especially in larger wheels.
it's setup with a 24s (88v nominal) battery pack, at 25ah, 40a ebike motor controller, 600lbs total mass, 26" bicycle wheels (about 19" motorcycle). it's not really accurate simulation of the kind of bike you're after, but only took 5 minutes to setup.
however, it's close enough to give you some idea of what you might need, again assuming completely flat roads with no wind and not caring about acceleration times, etc.
you'll see it's max speed at full throttle is 40.1mph, when the battery is about half charged (it will go a little faster at full charge, and a little slower as it gets closer to empty).
it's range at full throttle would be about 25 miles. (takes about 80wh/mile, which is basically like "gas mileage" for a gasoline powered bike).
it would take about 4kw of battery power to keep you at that speed.
it would take about 3kw of motor power to keep you at that speed. (the difference between 4kw and 3kw is all wasted as heat inside the controller and motor and wiring; that's a lot of heat).
acceleration is terrible, it will only increase by about 2mph per second from zero to around 15mph, then it drops off more and more until you're only gaining 1mph per second at around 25mph, and at 30mph you're only gaining half a mph per second, and so on, until you reach 40mph where it can't accelerate any more. so it would probably take something like 10 seconds or more to reach 20mph...my sb cruiser trike, which is just an electric bicycle class type, would do that in half the time or less! but it has 2wd and smaller wheels that don't go as fast but they push harder (more torque). then it would probably take another 20 seconds or more to reach 40mph from there. meaning, traffic behind you would not be very happy, if it takes more than 30 seconds to reach just 40mph.
you can fix the acceleration by using a much heftier controller (and a motor that can take the extra power), but it takes more battery power to do that, and it is also harder on the battery. so it also needs a bigger and better battery.
a comparison simulation of the previous setup as system a, and then a much higher power setup (but same motor) as system b
https://www.ebikes.ca/tools/simulator.html?motor=MX4504&batt=cust_88_0.2_25&cont=C40&hp=0&mass=272&frame=fat&axis=mph&cont_b=cust_200_400_0.03_V&motor_b=MX4504&batt_b=cust_88_0.2_25&frame_b=fat&mass_b=272&hp_b=0&bopen=true
cuts the range by a few miles, but it accelerates a lot harder, and even has a higher top speed by a couple mph. acceleration jumps to about 5mph per second from 0-15, so it only takes 3 seconds to do that part, then drops off, i'd guess you could probably hit 40mph in 10-15 seconds.
upping the battery voltage to 104v average
https://www.ebikes.ca/tools/simulator.html?motor=MX4504&batt=cust_88_0.2_25&cont=C40&hp=0&mass=272&frame=fat&axis=mph&cont_b=cust_200_400_0.03_V&motor_b=MX4504&batt_b=cust_104_0.2_25&frame_b=fat&mass_b=272&hp_b=0&bopen=true
gives a max of 48mph, and probably takes a few seconds off the acceleration time. it also increases the range because at the higher voltage, but same ah capacity, there's more wh capacity, which basically means a bigger "fuel tank".
changing to a "cromotor" (hyped up qsmotor rebuild, iirc)
https://www.ebikes.ca/tools/simulator.html?motor=MX4504&batt=cust_88_0.2_25&cont=C40&hp=0&mass=272&frame=fat&axis=mph&cont_b=cust_200_400_0.03_V&motor_b=MCRO5004_Sinks&batt_b=cust_104_0.2_25&frame_b=fat&mass_b=272&hp_b=0&bopen=true
fixes the overheating problem and increases the speed a little, and acceleration a little.
changing to a smaller 20" (16" mc) wheel greatly changes the situation, lowering speed (but still over 40 top speed) and increasing accleration and lowering motor temperatures
https://www.ebikes.ca/tools/simulator.html?motor=MX4504&batt=cust_88_0.2_25&cont=C40&hp=0&mass=272&frame=fat&axis=mph&cont_b=cust_200_400_0.03_V&motor_b=MCRO5004_Sinks&batt_b=cust_104_0.2_25&frame_b=fat&mass_b=272&hp_b=0&bopen=true&wheel_b=20i
anyway, those are just some playing with numbers.
it basically shows you that you're going to need a minimum of a 3kw motor / 4kw controller, and a minimum of a 24s 88v 25ah battery capable of a minimum of 40-50a continous. more is better for all of those, but especially the battery; it's the heart of the system, all the power comes from it, and if it can't handle the demands on it, it'll age faster and also sag in voltage more, so you get less response out of it, and your system doesn't do what you want.
also...more range than you need, by at least 20%, is better, because then you have "extra" for when you have headwinds or detours, so you still make it where you're going, and also have some headroom for pack aging, as it will lose capacity over time. double what you think you need doesn't hurt if the budget and the space on the bike allows for it...except that it'll be twice as big and twice as heavy (but twice as capable, too).
an 8kw+ motor / controller and battery capable of supporting that would be much more fun, and possibly safer in traffic so you don't get run over from behind by impatient drivers at stop lights / etc.
