☀️

【VRChat】動くガリレオ温度計を作ってみた

に公開

はじめに

自分の作ったワールドにガリレオ温度計を置きたい!

アタラクシアプロジェクト様の作成された温度計を基に実際の気温に応じてガラス球が上下するガリレオ温度計を作成しました。

ガラス球の移動について数年ぶりに力学の計算を行いましたので、せっかくなので記事にまとめることにしました。

もし間違いがあれば優しくマサカリを投げていただけると幸いです。

作ったもの

zennは動画が載せられないのでYouTubeで共有

https://youtube.com/shorts/YLtjU5ohfEU?feature=share


気温を取得する

気温の取得には Open-Meteo API を利用しました。
商用でなければ無料で利用可能でかつAPIキーも不要で、簡単なGETメソッドでデータを取得できます。

private VRCUrl url = new VRCUrl(
    "https://api.open-meteo.com/v1/forecast?latitude=35.6416&longitude=139.6724&hourly=temperature_2m&timezone=Asia%2FTokyo&forecast_days=1"
);

ガラス球を動かす

ガリレオ温度計内の球体を仮定したガラス球の運動に関わる力は以下の画像の三要素とし、運動方程式で記述します。

運動方程式の立式

温度依存パラメータ

  • 水の密度: \rho_{T} = f(T)[\mathrm{kg/m^3}]
  • 水の粘性係数: \mu_{T} = g(T)[\mathrm{kg/(m \cdot s)}]

定数・変数

  • 現在の流体温度:T_{current}[^\circ\mathrm{C}] or [\mathrm{K}]
  • ガラス球が沈む基準温度:T_{a}[^\circ\mathrm{C}] or [\mathrm{K}]
  • ガラス球の半径:r[\mathrm{m}]
  • ガラス球の体積:V[\mathrm{m}^3]
    • V = \frac{4}{3}\pi r^3で表せますが、式が複雑になるので別途定義

力の図(y方向)

  • 浮力: \rho_{T_{current}} V g[\mathrm{N}]
  • 重力: \rho_{T_{a}} V g[\mathrm{N}]
  • 粘性抵抗: 6\pi \mu_{T_{current}} r y'[\mathrm{N}]
    • ストークスの法則が成立することを仮定

立式

\rho_{T_ {a}} V\,y'' \;=\;\rho_{T_ {current}} V g\;-\;\rho_{T_ {a}} V g\;-\;6\pi \mu_{T_ {current}} r\, y'

運動方程式を速度 v=y' について解く

まず両辺を \rho_{T_ {a}} V で割り、

y'' + \frac{6\pi \mu_{T_\mathrm{current}} r}{\rho_{T_a} V}\,y' = \frac{\rho_{T_\mathrm{current}} - \rho_{T_a}}{\rho_{T_a}}\,g

ここで y' = vy'' = v' とおき、一次の線形常微分方程式とする:

v' + a v = b \tag{*}

ただし

  • a = \frac{6\pi\mu_{T_\mathrm{current}}r}{\rho_{T_{a}} V}
  • b = \frac{\rho_{T_\mathrm{current}} - \rho_{T_{a}}}{\rho_{T_{a}}}g

この方程式の一般解は

v(t) = \frac{b}{a} + C\,e^{-a t}

式に具体的な値を戻すと

v(t) = \frac{\rho_{T_\mathrm{current}} - \rho_{T_a}}{6\pi \mu_{T_\mathrm{current}} r} g V + C\,\exp\left(-\frac{6\pi \mu_{T_\mathrm{current}} r}{\rho_{T_a} V} t\right)

「最初は静止(初速度ゼロ)」を仮定すると Cについて以下の式がなりたつ:

0 = \frac{\rho_{T_\mathrm{current}} - \rho_{T_a}}{6\pi \mu_{T_\mathrm{current}} r} g V + C

すなわち

C = -\frac{\rho_{T_\mathrm{current}} - \rho_{T_a}}{6\pi \mu_{T_\mathrm{current}} r} g V

これを一般解に代入して特殊解は、

\boxed{ v(t) = y'(t) = \frac{\rho_{T_\mathrm{current}} - \rho_{T_a}}{6\pi \mu_{T_\mathrm{current}} r} g V \left[1 - \exp\left(-\frac{6\pi \mu_{T_\mathrm{current}} r}{\rho_{T_a} V} t\right)\right] }

水の密度・粘度関数

密度 \rho(T)

ITS-90 温度スケール(5 ℃ ≤ T ≤ 40 ℃)での経験式[1]

\rho(T) =999.85308 +6.32693\times10^{-2}T -8.523829\times10^{-3}T^2 +6.943248\times10^{-5}T^3 -3.821216\times10^{-7}T^4 \;

動粘性係数 \mu(T)

純水の粘性を絶対温度 T(K)から推定する Vogel–Fulcher 型経験式[2]

\mu(T) =A\times10^{\displaystyle\frac{B}{T-C}} \quad \bigl(A=2.414\times10^{-5}\,\mathrm{Pa\cdot s},\; B=247.8\,\mathrm{K},\; C=140\,\mathrm{K}\bigr)

実装

vのtについての関数を解きましたが、結局実装したのは速度についてのtについての式になります(微分方程式は解きたかっただけ)。

void Update(){
    velocity += (b - a * velocity) * dt; // 運動方程式の解いてる過程の*の式を用いる
    float dy = velocity * dt; // 速度から単位時間あたりの実際の移動量を計算

    Vector3 pos = fObj.transform.localPosition;
    pos.y += dy; // 位置座標を更新
}

おわりに

ワールドに置いてるから遊びに来てね!

https://vrchat.com/home/world/wrld_4af42284-d314-4eab-b322-e89b399738f5/info


脚注
  1. Frank E. Jones & Georgia L. Harris, “ITS-90 Density of Water Formulation for Volumetric Standards Calibration,” J. Res. Natl. Inst. Stand. Technol. 97, 335–342 (1992). ↩︎

  2. Saylor Academy, “Viscosity: Vogel–Fulcher Equation,” Viscosity Notes (2011). ↩︎

Discussion