I am wondering, what mechanism would be needed to generate gravity on a space ship in interstellar space, like we see it on Star Trek or Star Wars? What is the most realistic hypothetical way what would be achieved?
Most realistic way is centripetal force, which is the rotating wheel that you see on space stations and ships in movies.
Linear acceleration also works, but requires you to maintain constant thrust.
Sci-fi ways to do it...
If you had room temperature super conductors, you could use super conducting magnets to produce diamagnetic fields. They have levitated a mouse that way. It would require a very strong magnetic field, and it is unknown what prolonged effects that would have on living organisms. (You can do it without room temperature super conductors, but it would be easier).
Gravitomagnetism might work, but that's kind of out there. Currently they've only generated 100 millionths of a g. With the right breakthroughs that could be improved...
string theory predicts that gravity and electromagnetism unify in hidden dimensions, so artificial is probably possible with the right knowledge.
Really, unless you want to go with the rotating ring or linear acceleration, you're going to have to hand wave a lot of stuff, so it's probably better to just say "It works" and not explain how, unless it's super important. Just like they do in Star Trek and Star Wars.
Silly Edit: One thing that we know works is mass. So if you were to weave fine neutronium filaments into the carpet, then the resulting mass could have enough gravity pull you down toward the floor...
Edit 2: So a less silly edit. I was thinking about it some more, and I remembered another possibility: The Graviton. It's a theoretical particle, but if they discover it, it will unite quantum theory with gravity. So let's say at some point in the near future that the Graviton is discovered*, and then someone figures out how to generate them to create a (directed) gravitational field. This would also work for tractor beams, which could be a focused graviton laser, and repulsor fields to get an "Anti-Gravity" effect. Graviton drives could be used to take off from planets and for in-system propulsion by attracting or repulsing the planet's/sun's gravity.
* Maybe using the first space particle accelerator, which rings Jupiter and uses the planets power to operate. It had to be a space based accelerator because earth's gravity pushes all generated gravitons away before they can be seen.
It sounds a bit mad - but I'm actually sure I got this idea from a film/series that I can't remember - basically you pair the magnetized floor/boots idea with a power harness which actively pulls you towards your boots, kind of like a puppet in reverse.
It lets you everything else gravity-free - like sleeping in a sleeping bag glued to the wall and drinks that float through the air - while keeping everyone firmly on their feet during normal operations.
Now that I think about it, the idea might have been used in the Defying Gravity (2009) series, how's that for irony.
I am not sure about it. It is rather a theoretical idea of mine. Everyone knows, that mass increases when a spaceship gets more near to the speed of light. Thats from Einsteins relativity theory. At leasts this aspect is always used to explain why it is impossible to reach speed of light: Because your spaceship will show more and more inertia because of increased mass.
In the linked wikipedia section about relativistic mass they also denote that nowadays the term "relativistic mass" isn't welcome by some physicists. It is stated that people may thend to believe that increased velocity (or charge) causes a change of internal structure. Which is not the case in my model either. I build my idea upon the fact that a body becomes more and more heavy to accelerate as it reaches speed of light.
The idea is:
Place a solid ring below the mentioned carpet. The ring should rotate almost at the speed of light. First this would stabilize your ship and second the mass rotating at that very high speed would be that heavy that it generates enough gravitational force to act as articificial gravity for your travelers.
I am not sure about this use of relativity. Maybe I am getting it wrong. Is it known whether an object having its outside rotating almost at the speed of light seems to increase it's mass (and thus gravity) from a non-moving observer??
Of course you would have to find a materials which can take the high forces being caused by centripedal force on the disc.
I already tought a lot about this and if this maybe is even the reason why any particles are showing mass at all. Think of a proton having some quarks in it which oscillate at such a high frequency (and speed) that they are "relatively" heavy and cause gravity.
Thus mass would be a result of moving materia (particles).
Let's go completely Terry Pratchet / Hitchiker's Guide!
You attach a huge bladder containing some heavy, but fluid liquid to the underside of your ship and fill it with, say one earth mass of liquid to obtain 1 g of gravity.
However, this ship will, of course be impossible to move, so while accelerating or decelerating you suck the liquid into a pocket universe...
And for some, to us yet unknown physical reason, or perhaps quality of the pocket universe, the content of the pocket universe can be accelerated or decelerated along with the ship, however at much less mass... let's say one kilogram.
Then, when you've reached cruising speed, inflate the bladder and have a dance!
Not sure if someone else has already said this but here's my idea-
You have your ship, probably one or two levels. Each level has the same floor, so Bob can be walking on level 1, but to someone viewing on level 2 Bob is walking on the ceiling. How? The floor material is dense enough make a strong enough gravity field to hold humans to it. Going between levels is just walking through a big U to the other level so you end up upside down in relation to the other floor you were on. Your ship, or at least the interior where everyone is, will probably be a disk(but it could be any shape) with rounded edges so you can enter/exit other floors basically anywhere on the perimeter. This will definitely require some hand-waving to work, and I'm 99% sure we can't do this with today's technology.