This is what I know: A reversible process is a process which occurs
infinitesimally slowly.
That is correct, with one stipulation. The process must also involve no friction, since a process can proceed slowly (quasi-statically) with friction, which would make the process irreversible.
If you're isothermally compressing a gas infinitesimally slowly, the
walls of the container decrease (compress the gas) infinitesimally
slowly such that there is no acceleration.
Correct again.
And hence the walls do not impart a force to the particles in the
container (the force would change the kinetic energy of the
particles).
Not correct. The gas will not compress unless there is a net force applied. The key, however, is the net force is infinitesimal. That is, the external pressure is infinitesimally greater than the gas pressure throughout the process so that the gas slowly compresses while essentially remaining in mechanical and thermal equilibrium with the surroundings. This, in turn, results in an infinitesimally slow transfer of heat out of the gas equal to the infinitesimally slow amount of work done on the gas during compression. In the case of an ideal gas, there is no change in internal energy and, for an ideal gas, no change in temperature (internal kinetic energy).
But what if you isothermally compress a gas quickly? Then the walls
would have an acceleration and should hence impart a force to the
molecules and increase the translational kinetic energies of the
particles, right?
That is correct. But in order to have the irreversible isothermal compression occur between the same two states as the reversible isothermal compression, there are two sub-processes involved with the overall irreversible process.
See the diagram below. Path 1-2 is a reversible isothermal compression. Path 1-1a-2 is an irreversible isothermal compression between the same two equilibrium states. Process 1-1a represents what you refer to as the "quick compression". The external pressure is abruptly increased. It happens so quickly that there is no time for the volume to change nor for there to be heat transfer out of the gas. Because the temperature at the boundary between the gas and the surrounding thermal reservoir is the same and constant the process is called isothermal, but there are significant temperature and pressure gradients within the gas behind the boundary, generating entropy in the gas because the gas is not in equilibrium.
So, the internal energy (internal energy is sum of kinetic energies of
all particles according to what we have been taught) would change. But
internal energy does not change during isothermal irreversible
compression according to my textbook
For process 1-1a there is indeed an increase in internal energy. But we have not yet reached the same equilibrium state (state 2) as the reversible process. Your book is referring to the final state 2, not the intermediate state 1a. After abruptly increasing the pressure in process 1-1a when there was no time for the gas to compress, we now allow the gas to naturally compress from state 1a to state 2 at constant external pressure. During the compression heat transfers out of the gas and the temperature throughout the gas (and not just at the boundary) reaches equilibrium with the surroundings. The final temperature at state 2 is now the same as state 1, so there is no overall change in internal energy, as per your textbook.
Edit; One more question: According to my textbook, change in entropy
is zero for reversible isothermal compression and non zero for
irreversible isothermal compression. Why is that so?
I don't think you textbook is saying the change in entropy of the system for the reversible isothermal compression process itself is zero. It's probably saying the total entropy change of the system plus surroundings is zero, which is true. I suggest you re-read it.
The entropy change of the system alone is not zero for the reversible compression process. The change in entropy of the system is
$$\Delta S_{sys}=\frac{-Q}{T}$$
It is minus because the heat $Q$ is transferred out of the system to the surroundings. Since the process is reversible, the change in entropy of the surroundings is
$$\Delta S_{sur}=\frac{+Q}{T}$$
For a total entropy change of zero.
For the irreversible isothermal compression, the change in entropy of the system is the same as the reversible process, that is, $\frac{-Q}{T}$, because entropy is a state function. But in order for the system entropy to return to its original state, the extra entropy generated with the system due to the irreversible process had to be transferred to the surroundings in the form of heat. In other words, for the irreversible compression the change in entropy of the surroundings will be
$$\Delta S_{sur}=\frac{+Q}{T}+σ$$
Where $σ$ = entropy generated within the system due to irreversibility.
So now the total entropy (system + surroundings) is
$$\Delta S_{tot}=\Delta S_{sys}+\Delta S_{sur}=\frac{-Q}{T}+\frac{+Q}{T}+σ$$
$$\Delta S_{tot}=σ>0$$
Which is why your textbook says "$\Delta S_{sys}+\Delta S_{sur}$ is not zero for irreversible process". It equals the entropy generated in the system, σ.
At some point you should learn you how to calculate σ.
PS- If you would like to see a worked out example, check out the following: http://pillars.che.pitt.edu/student/slide.cgi?course_id=19&slide_id=38.0
I didn't know there is entropy generated due to irreversibility. But
why is it so? Entropy is a state function so it must only depend on
initial and final states right?
Regarding the details of how irreversibility generates entropy, I don’t have as deep an understanding of the details of the mechanisms as some others, notably @Chet Miller in particular. For one thing it involves a deeper understanding of fluid mechanics, that I don't possess.
But as I understand it, one reason is that pressure gradients exist in the gas due to the sudden increase in external pressure in the irreversible process. These gradients result in internal viscous work (a.k.a, fluid friction work). You may have learned friction dissipates energy in the form of heat that would otherwise be available to perform mechanical work. That's as far as I can take it. But @Chet Miller provides a cool mechanical analog involving springs and dampers, where spring compression and extension represent reversible work, while the dampers represent irreversible friction work. For details see one Chet’s answers in the following link: Released-absorbed heat relation in irreversible process. Note that damping friction goes to zero as the piston velocity approaches zero (quasi-static condition).
You are correct entropy is a state function (system property) that only depends only on the initial and final states. Entropy generation is always a positive quantity or zero (for a reversible process). Since its value depends on the process, entropy generation is not a property of the system. Consequently in order for the property of entropy of the system to be the same between two states, any entropy generated in the system must be transferred out of the system to the surroundings in the form of heat. This means the increase in entropy of the surroundings will be greater for an irreversible process than a reversible process, or $\Delta S_{tot}>0$. The original link I gave you will provide an example calculation of entropy generation.
I should add that for a step by step approach to determine the change in entropy of a system, check out Grandpa Chet's Entropy Recipe in the following link: https://www.physicsforums.com/insights/grandpa-chets-entropy-recipe/
Hope this helps.
