이것은 프로그래밍 문제만큼 수학 문제 일 가능성이 높지만 높은 값 (1000)으로 설정하면 클래스 메서드 "update()"에서 온도에 심한 진동이 발생하는 것처럼 보입니다. +). 모든 온도는 단순화를 위해 켈빈 단위입니다.제어 할 수없는 시뮬레이션 진동
는 (. 내가 직업으로 프로그래머가 아니다이 서식 가능성이 불쾌한입니다.)
import math
#Critical to the Stefan-Boltzmann equation. Otherwise known as Sigma
BOLTZMANN_CONSTANT = 5.67e-8
class GeneratorObject(object):
"""Create a new object to run thermal simulation on."""
def __init__(self, mass, emissivity, surfaceArea, material, temp=0, power=5000, warp=1):
self.tK = temp #Temperature of the object.
self.mass = mass #Mass of the object.
self.emissivity = emissivity #Emissivity of the object. Always between 0 and 1.
self.surfaceArea = surfaceArea #Emissive surface area of the object.
self.material = material #Store the material name for some reason.
self.specificHeat = (0.45*1000)*self.mass #Get the specific heat of the object in J/kg (Iron: 0.45*1000=450J/kg)
self.power = power #Joules/Second (Watts) input. This is for heating the object.
self.warp = warp #Warp Multiplier. This pertains to how KSP's warp multiplier works.
def update(self):
"""Update the object's temperature according to it's properties."""
#This method updates the object's temperature according to heat losses and other factors.
self.tK -= (((self.emissivity * BOLTZMANN_CONSTANT * self.surfaceArea * (math.pow(self.tK,4) - math.pow(30+273.15,4)))/self.specificHeat) - (self.power/self.specificHeat)) * self.warp
사용하는 법은 블랙 바디 열 손실 계산하는 슈테판 - 볼츠만 법칙이다 :
온도를 - = (방사율 * 시그마 * SurfaceArea * (Temp^4-Amb^4))/SpecificHeat)
이것은 빠른 디버깅을 위해 KSP 플러그인에서 이식되었습니다. Object.update()는 초당 50 회 호출됩니다.
단계별로 코드를 여러 번 실행하지 않는 극한 진동을 방지 할 수있는 해결책이 있습니까?
시간 간격이 해당 방정식의 요소가 아니어야합니까? – Beta
내가 묻는 것을 시뮬레이션하려고 시도했지만 matlib 패키지를 찾을 수 없습니다. 초기화 매개 변수도 유용 할 수 있습니다. – MiooiM
matlib를 호출하는 대신에, self.specificHeat를 450으로 설정하십시오. 코드에서 여분의 모듈을 제거하지 않았습니다. Obj = GeneratorObject (100,0.93, 10, "iron", 0,0,1) self.Warp가 500을 초과하면 일반적으로 범위를 벗어난 오류가 발생합니다. – Calrizan