What causes an electron and proton to combine into a neutron? I know that electrons and protons can interact with each other via the weak force to form a neutron and an electron neutrino. This can happen as a result of electron capture or during the formation of a neutron star.
However, what I'm struggling to understand is: what enables this interaction? I know that electron capture occurs when there is an excess of protons in the nucleus. But, as far as I understand, the wavefunction of an electron is already centred on the nucleus, so what effect do the excess protons have on it? Perhaps even more counterintuitively, during the formation of a neutron star, one would intuitively expect the high temperatures to result in electrons increasing their energy levels, which should only decrease the probability of the electrons interacting with the nucleus; however, the exact opposite happens, and the weak interaction is triggered.
Bizarrely, despite electron capture being literally part of most high-school curricula, I can't find any information at all on how an excess of protons in the nucleus or high temperatures trigger election capture. Could somebody please clear this up?
 A: The relevant interaction is represented by Beta decay. The connecting particle is a charged weak particle, in the diagram a $W^-$.

An isolated neutron can decay to a proton, electron, and electron anti-neutrino. This is because the mass of a neutron is slightly higher than the masses of the three product particles. So the energy balance allows the interaction to move from neutron to resultant products.
In certain nuclear structures, the energy difference is in the other direction. Suppose the starting nucleus has N neutrons and P protons, then it may be that the mass of the nucleus with N+1 neutrons and P-1 protons is slightly lower. In this circumstance it may be energetically favorable for the nucleus to capture an electron and move to the lower mass configuration.
One interesting feature of electron capture is that the rate can be affected by the electron wave function. For example, $^7Be$ shows a different electron capture rate if it is in metalic form or in oxidized form.
In a neutron star a different factor can arise. Return to the figure. Notice that the electron and proton come out of Beta decay with a range of energies. Suppose that the density of protons and electrons in the neutron star material is high enough such that these energy levels are essentially full. When a neutron is about to decay, the decay products have nowhere to go. Or, looked at another way, the decay products are bouncing around in such abundance that the reverse interaction to Beta decay begins to happen at an appreciable rate.
So when protons are crushed together sufficiently densely, there will begin to be some neutrons produced. And at high enough density, this production will reac an equilibrium with the decay of the neutrons. The specific relative amounts in this equilibrium will depend on the density and temperature.
A: The "weak charged current" is associated with a particle called the $W$, which can have either electrical charge, usually written $W^\pm$.  Particles which interact with the charged current, which are the six quarks and six leptons of the standard model, can be thought of as different states of their partners in a direction called "isospin space," and the $W^\pm$ is the operator which causes rotations between one particle flavor and its partner.
That is to say, there is a very real way in which the electron and the electron-flavored neutrino are different states of the same particle, and transitions like
$$\mathrm e^- \longleftrightarrow W^-\nu_\mathrm e \quad\text{or}\quad \mathrm e^-W^+\longleftrightarrow\nu_\mathrm e$$
are allowed to happen just all the time, unless there is some other rule which prevents it.  The most common reason these flavor oscillations don't  happen is energy conservation. The $W$ is very heavy, so there has to be an awful lot of energy kicking around to end up with a real $W$ particle in the final state.
In a reaction where you have
$$
\text{(stuff)} + \mathrm p + \mathrm e^- \stackrel?\longrightarrow{}
\text{(stuff)} + \mathrm n + \nu_\mathrm e
$$
it may or may not be the case that the total mass-energy of the initial state on the left can be more than the total mass-energy of the final state on the right.  If the (stuff) is the vacuum, there's not enough energy to proceed unless the electron and proton both have a lot of kinetic energy; therefore hydrogen atoms can't decay by electron capture.  But if the $(\text{stuff}+\mathrm p)$ is a potassium-40 nucleus, then $(\text{stuff}+\mathrm n)$ is an argon-40 nucleus.  You might imagine that argon-40 is more tightly bound than potassium-40 because there are fewer positively-charged protons in the nucleus to mutually repel each other.  (Homework assignment: look up all the decays of potassium-40 and convince yourself electrical repulsion isn't a great argument for this particular mass number.)
If the decay is allowed energetically, you can have the two isospin rotations
$$
\mathrm p \to W^+ \mathrm n \quad\text{and}\quad W^+ \rm e^- \to \nu_e
$$
using the same $W^+$.  (You can also imagine a $W^-$ if you put the electron transition "first.")  Because the $W$ doesn't exist in the final state, we actually don't need the decay to have enough energy to create it at all. We can say instead that the decay is mediated by a "virtual $W$," or even that the decay is mediated by "the charged weak current."
If you want to compute the rate at which these decays occur, you have to know something about how strongly the weak interaction couples to the different particles involved.  Those coupling constants are feeble (thus the name "weak interaction"), so weak decays tend to be much slower than electromagnetic or strong decays.
