Learning Thermodynamics in Roblox

It definitely increases. I’m running the test after the fix.

Likely Culprit:
With PGS we use a “collision resolution” trick when two objects are caught interpenetrating. Interpenetration is a natural phenomenon in discreet physics engines, so the new solver basically takes the part and moves it out of the collision (without adding any velocity). In a system like this, where majority of the collisions are with the floor (due to gravity and so on, and the starting state), by displacing the part upwards, you are actually adding potential energy into the system.

So it’s possible/most likely that the energy slowly increases due to this collision resolution step. It introduces extra potential energy.

Hmm, alright. I also get weird drops in energy like these:

I’ve got no idea how to reproduce but it happens.

Eliminating the balls that shoot out of the container might be a good idea too, might cause weird drops like that.

EDIT: And do what someone suggested, throw in bodyforces to turn gravity off, and initialize the system with more kinetic energy on one side (instead of more potential energy). Just to see if the penetration solving is the major issue here.

Putting BodyForces on objects shouldn’t be too much slower with the new solver. Should be much faster than the old solver (* I think).

Also, yeah total energy drops could easily be because we are losing high-energy balls out of the system.

Update:

There were 2 things going on:

[ul]
[li]Energy leaks were caused when balls would leave the system. This was a bug with Ball-Block collisions, and we have a fix for it that will be out by mid Monday.[/li]
[li]Energy increase was caused by positional correction + gravity. Positional correction can alter energy state in any potential fields, and gravity is a constant potential field.[/li]

[/ul]
I made all the parts have 0 gravity and found that the energy only increases at 0.05% over a course of 15 minutes. Here is the updated code (Please note, this will probably leak energy until we make the Ball-Block fix public):

local AllBalls = workspace.AllBalls
local LG = BrickColor.new("Lime green")
local BG = BrickColor.new("Bright green")
local C = BrickColor.new("Camo")
local O = BrickColor.new("Olive")
local NO = BrickColor.new("Neon orange")
local MR = BrickColor.new("Medium red")
local BR = BrickColor.new("Bright red")
local totalEnergy = 0

wait(7)

function getTotalEnergy(part)
	local KE = ((part.Velocity.magnitude^2)*(part.Size.X^3)/70000)/2
	--local PE = ((part.Position.Y - 5) * 196.2) *(part.Size.X^3)/70000
	return KE-- + PE
end

for i,v in pairs(AllBalls:GetChildren())do
	totalEnergy = totalEnergy + getTotalEnergy(v)
end

for i,v in pairs(AllBalls:GetChildren())do
	bf = Instance.new("BodyForce", v)
	bf.force = Vector3.new(0, 196.2, 0) * v:GetMass()
	v.Anchored = false
end

print("ENERGY SHOULD INCREASE")
--game.Workspace.AllBalls.Driver1.Velocity = Vector3.new(200, -1, 200)
--game.Workspace.AllBalls.Driver2.Velocity = Vector3.new(-100, -1, -100)

print("Average Energy: " .. tostring(totalEnergy/#AllBalls:GetChildren()))
counter=1
while wait(0)do
for i,v in pairs(AllBalls:GetChildren())do
	if i%200==0 then wait(0)end
	local s = (v.Velocity.magnitude^2)*(v.Size.X^3)/70000
	if s<8 then
		v.BrickColor = LG
	elseif s<16 then
		v.BrickColor = BG
	elseif s<25 then
		v.BrickColor = C
	elseif s<45 then
		v.BrickColor = C
	elseif s<85 then
		v.BrickColor = O
	elseif s<100 then
		v.BrickColor = NO
	elseif s<130 then
		v.BrickColor = MR
	elseif s>180 then
		v.BrickColor = BR
	end
	counter = counter + 1
	
totalEnergy = 0
if counter%200==0 then
	counter = 0
	for i,v in pairs(AllBalls:GetChildren())do
		totalEnergy = totalEnergy + getTotalEnergy(v)
	end
	
	print("Average Energy: " .. tostring(totalEnergy/#AllBalls:GetChildren()))
end
end
end

What energy increase?

Sudden energy increases probably happen when I lose focus and refocus on studio.

Closer look to the value changing.

I told you we haven’t fixed the bug where balls magically leave the system. This will be available to you on Monday. You’re seeing energy drops because balls magically escape the container, and then they get deleted, and no longer are part of the energy of the system.

I’m talking about the increases, the big increases, like on the 2nd and 3rd images. I know about the drops.

Ah that. Hmmm, not sure. I need to investigate that. I may have seen a few large jumps. Hopefully it’s not BodyForce failing.

Am I a fool for not understanding any of this :Q.
I’m taking physics this year so maybe I’ll be able to understand it here in a few weeks :smiley: lol

[quote] Am I a fool for not understanding any of this :Q.
I’m taking physics this year so maybe I’ll be able to understand it here in a few weeks :smiley: lol [/quote]

You’d be better off and learn faster with videos on the internet or coursera.com