commit 7ea9f9b1b6c2d1a581b9b833541337a15f0d8719 Author: Spasol Date: Thu Nov 20 10:45:27 2025 +0800 1 diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..359bb53 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml diff --git a/.idea/asiaMath.iml b/.idea/asiaMath.iml new file mode 100644 index 0000000..3aae5ce --- /dev/null +++ b/.idea/asiaMath.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..da39e55 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,14 @@ + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..55800d0 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..8ff4795 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/org/__init__.py b/org/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/org/chatgpt2/__init__.py b/org/chatgpt2/__init__.py new file mode 100644 index 0000000..2b9397c --- /dev/null +++ b/org/chatgpt2/__init__.py @@ -0,0 +1,102 @@ +import numpy as np +import matplotlib.pyplot as plt +from scipy.interpolate import CubicSpline +from scipy.constants import h, c, k + +# ----------------------------- +# 1. 数据预处理 +# ----------------------------- +# PDMS 可见光折射率数据 +wl_data = np.array([0.3500,0.3535,0.3570,0.3605,0.3640,0.3675,0.3710,0.3745,0.3780,0.3815, + 0.3850,0.3885,0.3920,0.3955,0.3990,0.4025,0.4060,0.4095,0.4130,0.4165, + 0.4200,0.4235,0.4270,0.4305,0.4340,0.4375,0.4410,0.4445,0.4480,0.4515, + 0.4550,0.4585,0.4620,0.4655,0.4690,0.4725,0.4760,0.4795,0.4830,0.4865, + 0.4900,0.4935,0.4970,0.5005,0.5040,0.5075,0.5110,0.5145,0.5180,0.5215, + 0.5250,0.5285,0.5320,0.5355,0.5390,0.5425,0.5460,0.5495,0.5530,0.5565, + 0.5600,0.5635,0.5670,0.5705,0.5740,0.5775,0.5810,0.5845,0.5880,0.5915, + 0.5950,0.5985,0.6020,0.6055,0.6090,0.6125,0.6160,0.6195,0.6230,0.6265, + 0.6300,0.6335,0.6370,0.6405,0.6440,0.6475,0.6510,0.6545,0.6580,0.6615, + 0.6650,0.6685,0.6720,0.6755,0.6790,0.6825,0.6860,0.6895,0.6930,0.6965, + 0.7000]) +n_data = np.array([1.4585,1.4576,1.4567,1.4559,1.4550,1.4542,1.4535,1.4527,1.45197,1.45126, + 1.45057,1.44990,1.44926,1.44863,1.44802,1.44742,1.44685,1.44628,1.44574,1.44521, + 1.44470,1.44420,1.44371,1.44324,1.44277,1.44232,1.44188,1.44145,1.44104,1.44063, + 1.44024,1.43985,1.43947,1.43911,1.43875,1.43840,1.43805,1.43772,1.43739,1.43707, + 1.43676,1.43645,1.43616,1.43587,1.43558,1.43531,1.43503,1.43477,1.43450,1.43425, + 1.43399,1.43375,1.43351,1.43328,1.43305,1.43283,1.43260,1.43238,1.43217,1.43197, + 1.43177,1.43157,1.43137,1.43118,1.43098,1.43080,1.43062,1.43044,1.43027,1.43009, + 1.42993,1.42976,1.42960,1.42944,1.42929,1.42913,1.42898,1.42883,1.42869,1.42855, + 1.42841,1.42827,1.42813,1.42799,1.42787,1.42773,1.42761,1.42749,1.42736,1.42724, + 1.42712,1.42701,1.42689,1.42677,1.42666,1.42656,1.42645,1.42634,1.42624,1.42613, + 1.42604]) + +# 三次样条插值 +cs_n = CubicSpline(wl_data, n_data) + +# 定义厚度序列(μm) +thicknesses = [0.5, 1.0, 1.5, 2.0] + +# ----------------------------- +# 2. 发射率计算(小问1) +# ----------------------------- +def fresnel_reflectance(n1, n2): + return ((n1 - n2)/(n1 + n2))**2 + +def thin_film_reflectance(n_film, d, wl): + R12 = fresnel_reflectance(1.0, n_film) + R23 = fresnel_reflectance(n_film, 1.0) + delta = 2 * np.pi * n_film * d / wl + R = (R12 + R23 + 2*np.sqrt(R12*R23)*np.cos(2*delta)) / (1 + R12*R23 + 2*np.sqrt(R12*R23)*np.cos(2*delta)) + return R + +# 波长范围 0.35-0.7 μm,步长 0.001 +wl_fine = np.linspace(0.35, 0.7, 500) +plt.figure(figsize=(8,5)) + +emission_dict = {} +for d in thicknesses: + R = thin_film_reflectance(cs_n(wl_fine), d, wl_fine) + epsilon = 1 - R + emission_dict[d] = epsilon + plt.plot(wl_fine, epsilon, label=f"d={d} μm") + +plt.xlabel("Wavelength (μm)") +plt.ylabel("Emissivity ε(λ)") +plt.title("PDMS Thin Film Spectral Emissivity") +plt.legend() +plt.grid(True) +plt.show() + +# ----------------------------- +# 3. 净辐射功率计算(小问2) +# ----------------------------- +# 黑体辐射谱 (Planck) +def planck_spectrum(wl, T): + wl_m = wl * 1e-6 # μm → m + return (2*h*c**2 / wl_m**5) / (np.exp(h*c/(wl_m*k*T)) - 1) + +T_film = 300 # K +T_sky = 280 # K +# 假设太阳吸收率 alpha = 0.1 +alpha = 0.1 +# 假设太阳总辐射 1000 W/m² +I_sun_total = 1000 +I_sun = np.ones_like(wl_fine) * I_sun_total / len(wl_fine) +# 假设大气透射率 tau = 0.9 +tau_atm = 0.9 + +plt.figure(figsize=(8,5)) +for d in thicknesses: + epsilon = emission_dict[d] + P_emit = np.trapz(epsilon * planck_spectrum(wl_fine, T_film), wl_fine) + P_sun = np.trapz(alpha * I_sun, wl_fine) + P_atm = np.trapz(epsilon * planck_spectrum(wl_fine, T_sky) * tau_atm, wl_fine) + P_net = P_emit - P_sun - P_atm + print(f"d={d} μm, P_net = {P_net:.2f} W/m²") + plt.bar(d, P_net, width=0.3) + +plt.xlabel("Thickness (μm)") +plt.ylabel("Net Radiative Cooling Power (W/m²)") +plt.title("PDMS Thin Film Net Radiative Cooling") +plt.grid(True) +plt.show() diff --git a/org/q1.py b/org/q1.py new file mode 100644 index 0000000..c77992a --- /dev/null +++ b/org/q1.py @@ -0,0 +1,103 @@ +import numpy as np +import matplotlib.pyplot as plt +from scipy.interpolate import InterpolatedUnivariateSpline + +# ------------------------------------------------ +# 1. 可见光区 PDMS 折射率数据(题目给定) +# ------------------------------------------------ +wl_visible = np.array([ +0.3500,0.3535,0.3570,0.3605,0.3640,0.3675,0.3710,0.3745,0.3780,0.3815, +0.3850,0.3885,0.3920,0.3955,0.3990,0.4025,0.4060,0.4095,0.4130,0.4165, +0.4200,0.4235,0.4270,0.4305,0.4340,0.4375,0.4410,0.4445,0.4480,0.4515, +0.4550,0.4585,0.4620,0.4655,0.4690,0.4725,0.4760,0.4795,0.4830,0.4865, +0.4900,0.4935,0.4970,0.5005,0.5040,0.5075,0.5110,0.5145,0.5180,0.5215, +0.5250,0.5285,0.5320,0.5355,0.5390,0.5425,0.5460,0.5495,0.5530,0.5565, +0.5600,0.5635,0.5670,0.5705,0.5740,0.5775,0.5810,0.5845,0.5880,0.5915, +0.5950,0.5985,0.6020,0.6055,0.6090,0.6125,0.6160,0.6195,0.6230,0.6265, +0.6300,0.6335,0.6370,0.6405,0.6440,0.6475,0.6510,0.6545,0.6580,0.6615, +0.6650,0.6685,0.6720,0.6755,0.6790,0.6825,0.6860,0.6895,0.6930,0.6965, +0.7000 +]) + +n_visible = np.array([ +1.4585377,1.45761865,1.456730118,1.455870728,1.455039187,1.454234276,1.453454840, +1.452699788,1.451968089,1.451258766,1.450570894,1.449903597,1.449256044,1.448627445, +1.448017051,1.447424151,1.446848069,1.446288159,1.445743811,1.445214441,1.444699493, +1.444198438,1.443710771,1.443236009,1.442773692,1.442323382,1.441884657,1.441457118, +1.441040380,1.440634076,1.440237854,1.439851378,1.439474326,1.439106388,1.438747267, +1.438396681,1.438054357,1.437720031,1.437393455,1.437074386,1.436762592,1.436457851, +1.436159948,1.435868677,1.435583840,1.435305247,1.435032713,1.434766062,1.434505122, +1.434249731,1.433999730,1.433754966,1.433515292,1.433280566,1.433050651,1.432825415, +1.432604730,1.432388473,1.432176524,1.431968770,1.431765097,1.431565400,1.431369574, +1.431177518,1.430989136,1.430804333,1.430623017,1.430445102,1.430270501,1.430099132, +1.429930914,1.429765771,1.429603626,1.429444407,1.429288044,1.429134467,1.428983610, +1.428835410,1.428689802,1.428546727,1.428406125,1.428267940,1.428132115,1.427998598, +1.427867334,1.427738274,1.427611368,1.427486568,1.427363827,1.427243100,1.427124343, +1.427007511,1.426892565,1.426779463,1.426668165,1.426558634,1.426450831,1.426344720, +1.426240266,1.426137434,1.426036190 +]) + +# ------------------------------------------------ +# 2. 插值构建连续 n(λ) +# ------------------------------------------------ +interp_n = InterpolatedUnivariateSpline(wl_visible, n_visible) + +# ------------------------------------------------ +# 3. 红外区 n,k 数据(示例,可替换为真实数据) +# ------------------------------------------------ +def pdms_nk(lambda_um): + """ + 示例:构建红外折射率 n,k(实际请替换 refractiveindex.info 数据) + """ + n = 1.385 + 0.015 * np.exp(-(lambda_um - 10)**2 / 20) + k = 0.15 * np.exp(-(lambda_um - 10)**2 / 5) # 红外区 PDMS 有吸收峰 + # 可见光区用插值得到的 n + n[lambda_um < 0.7] = interp_n(lambda_um[lambda_um < 0.7]) + k[lambda_um < 0.7] = 0 # 可见光透明 + return n + 1j*k + +# ------------------------------------------------ +# 4. TMM 计算发射率 +# ------------------------------------------------ +def layer_matrix(n_complex, d_um, lambda_um): + k0 = 2 * np.pi / (lambda_um * 1e-6) + delta = k0 * n_complex * (d_um * 1e-6) + q = n_complex + M11 = np.cos(delta) + M12 = 1j / q * np.sin(delta) + M21 = 1j * q * np.sin(delta) + M22 = np.cos(delta) + return np.array([[M11, M12], [M21, M22]]) + +def emissivity(lambda_um, d_um): + n0 = 1.0 # 空气 + ns = 1.0 # 基底(可修改) + nk = pdms_nk(lambda_um) + + M = layer_matrix(nk, d_um, lambda_um) + M11, M12 = M[0,0], M[0,1] + M21, M22 = M[1,0], M[1,1] + + numerator = M11 + M12*ns - M21/n0 - M22*ns/n0 + denominator = M11 + M12*ns + M21/n0 + M22*ns/n0 + + R = np.abs(numerator/denominator)**2 + T = (ns/n0) / np.abs(denominator)**2 + return 1 - R - T + +# ------------------------------------------------ +# 5. 计算发射率与绘图 +# ------------------------------------------------ +lambda_range = np.linspace(0.35, 20, 2000) +d_pdms = 10 # 10 μm 厚度 + +eps = emissivity(lambda_range, d_pdms) + +plt.figure(figsize=(10,5)) +plt.plot(lambda_range, eps, label=f'd = {d_pdms} μm') +plt.xlabel("Wavelength (μm)") +plt.ylabel("Emissivity") +plt.title("PDMS Thin-film Emissivity Spectrum") +plt.grid(True) +plt.legend() +plt.show() diff --git a/org/q2.py b/org/q2.py new file mode 100644 index 0000000..6f2f033 --- /dev/null +++ b/org/q2.py @@ -0,0 +1,95 @@ +import numpy as np +from scipy.constants import h, c, k +from scipy.integrate import simps +import matplotlib.pyplot as plt + +from org.q1 import emissivity + + +# ------------------------------------------------ +# 1. 引用第一题的 emissivity() 函数 +# ------------------------------------------------ +# (假设已运行第一题代码) +# emissivity(lambda_um, thickness_um) + + +# ------------------------------------------------ +# 2. 黑体辐射谱 +# ------------------------------------------------ +def planck_lambda(lambda_um, T): + lambda_m = lambda_um * 1e-6 + return (2*h*c**2)/(lambda_m**5) / (np.exp(h*c/(lambda_m*k*T)) - 1) + +# ------------------------------------------------ +# 3. 大气透过率(示例,可替换 MODTRAN 数据) +# ------------------------------------------------ +def atmosphere_tau(lambda_um): + tau = np.ones_like(lambda_um) + window = (lambda_um >= 8) & (lambda_um <= 13) + tau[window] = 0.8 + tau[~window] = 0.1 + return tau + +# ------------------------------------------------ +# 4. 太阳辐照谱(简化 AM1.5) +# ------------------------------------------------ +def solar_spectrum(lambda_um): + I0 = 1.5e3 # simplified scaling + return I0 * np.exp(-(lambda_um - 0.5)**2 / 0.4) + +# ------------------------------------------------ +# 5. 能量项计算 +# ------------------------------------------------ +def P_rad(Ts, lambda_um, eps): + return simps(eps * planck_lambda(lambda_um, Ts), lambda_um) + +def P_atm(Ta, lambda_um, eps): + return simps(eps * planck_lambda(lambda_um, Ta) * (1 - atmosphere_tau(lambda_um)), lambda_um) + +def P_solar(lambda_um, eps): + A = eps # approximate absorption + return simps(A * solar_spectrum(lambda_um), lambda_um) + +def P_conv(Ts, Ta, h=5): + return h * (Ts - Ta) + +# ------------------------------------------------ +# 6. 净冷却功率 +# ------------------------------------------------ +def P_net(Ts, Ta, lambda_um, eps, h=5): + return P_rad(Ts, lambda_um, eps) - P_atm(Ta, lambda_um, eps) - P_solar(lambda_um, eps) - P_conv(Ts, Ta, h) + +# ------------------------------------------------ +# 7. 求稳态温度(解 Pnet=0) +# ------------------------------------------------ +def solve_temperature(Ta, lambda_um, eps): + Ts = Ta + for _ in range(1000): + f = P_net(Ts, Ta, lambda_um, eps) + Ts -= 0.1 * f # simple iteration + return Ts + +# ------------------------------------------------ +# 8. 运行示例 +# ------------------------------------------------ +lambda_range = np.linspace(0.35, 20, 2000) +d_pdms = 10 +eps = emissivity(lambda_range, d_pdms) + +Ta = 300 # 环境温度 +Ts = solve_temperature(Ta, lambda_range, eps) + +print("Steady-state temperature:", Ts) + +# 曲线可视化 +T_list = np.linspace(250, 330, 200) +P_list = [P_net(T, Ta, lambda_range, eps) for T in T_list] + +plt.figure(figsize=(10,5)) +plt.plot(T_list, P_list) +plt.axhline(0, color='r') +plt.xlabel("Temperature (K)") +plt.ylabel("Net Cooling Power") +plt.title("Cooling Power vs Temperature") +plt.grid(True) +plt.show() diff --git a/requurement.txt b/requurement.txt new file mode 100644 index 0000000..e69de29