普朗克-黑体单色辐射力曲线绘制

2019-11-18 22:58:57 浏览数 (3)

天才普朗克凭借深厚数学功底,总结前人数据,得到了统一的全波段的单色辐射力公式,并推动了量子力学的发展。

绘制光谱辐射力曲线如下,根据动画,可以明显感知相同波长时不同温度下单色辐射力的不同:

微信小程序体验请点击 普朗克黑体单色辐射力

Talk is cheap, show me the code:

代码语言:javascript复制
//Pages/sun/index.js
import * as echarts from '../../ec-canvas/echarts';

const app = getApp();
var [lmd, T173, T300, T1000,T2000]=[[],[],[],[],[]];

const c1=3.741e-16,c2=1.4388e-2;
let T=300;
var Planck=(L)=>{L/=1e6; return 1e-9*c1/(Math.exp(c2/L/T)-1)/L**5};//结果放大1E-9
function calcData(){
  for(var i=0.35;i<15;i=i 0.1){
    lmd.push(i);
  }
  T=173;
  T173 = lmd.map(Planck);
  T=300;
  T300 = lmd.map(Planck);
  T = 1000;
  T1000 = lmd.map(Planck);
  T = 2000;
  T2000 = lmd.map(Planck);
}

var chart=null;
function initLineChart(canvas, width, height) {
  chart = echarts.init(canvas, null, {
    width: width,height: height
  });
  canvas.setChart(chart);

  var option = {
    title: {
      text: '不同温度黑体单色辐射力',
      left: 'center'
    },
    color: ["#00FF00", "#000000", "#0000FF", "#FF0000"],
    legend: {
      data: ['173K','300K','1000K','2000K'],
      top: 25,left: 'center',z: 100
    },
    grid: {
      containLabel: true
    },
    tooltip: {
      show: true,
      trigger: 'axis'
    },
    xAxis: {
      type: 'category',
      boundaryGap: false,
      data: lmd,
      // show: false
    },
    yAxis: {
      x: 'center',
      type: 'value',
      splitLine: {
        lineStyle: {
          type: 'dashed'
        }
      }
      // show: false
    },
    series: [{
      name: '173K',
      type: 'line',
      smooth: true,
      data: T173
    }, {
      name: '300K',
      type: 'line',
      smooth: true,
      data: T300
    }, {
      name: '1000K',
      type: 'line',
      smooth: true,
      data: T1000
      }, {
        name: '2000K',
        type: 'line',
        smooth: true,
        data: T2000
      }]
  };

  chart.setOption(option);
  return chart;
}

Page({
  onShareAppMessage: function (res) {
    return {
      title: '单色辐射力!',
      //path: '/pages/logs/logs',
      success: function () { },
      fail: function () { }
    }
  },
  data: {
    logs: [],
    ec: {onInit: initLineChart}
  },
  onLoad: function () {

  },
  onHeat1D:function(){
    calcData();
    chart.setOption({ xAxis:{data:lmd}});
    chart.setOption({ series: [{ data: T173 }, { data: T300 }, { data: T1000 }, { data: T2000 }] });
  },
  formReset:function(){

  }
})

摘录其中的计算函数如下:

代码语言:javascript复制
var [lmd, T173, T300, T1000,T2000]=[[],[],[],[],[]];

const c1=3.741e-16,c2=1.4388e-2;
let T=300;
var Planck=(L)=>{L/=1e6; return 1e-9*c1/(Math.exp(c2/L/T)-1)/L**5};//结果放大1E-9
function calcData(){
  for(var i=0.35;i<15;i=i 0.1){
    lmd.push(i);
  }
  T=173;
  T173 = lmd.map(Planck);
  T=300;
  T300 = lmd.map(Planck);
  T = 1000;
  T1000 = lmd.map(Planck);
  T = 2000;
  T2000 = lmd.map(Planck);
}

没错使用了百度echarts组件库!再次感谢百度!(https://www.echartsjs.com/zh/index.html)

0 人点赞