import matplotlib.pyplot as pltfrom matplotlib.ticker import FuncFormatter#数学公式包
"""
np.pi
np.cos(此处输入的是弧度制)
np.sqrt()
np.sin()
平方是**
"""import numpy as np"""
def 函数名字(输入参数)return
"""#公式
def fresnel(theta, n1, n2):theta = theta*np.pi/180xTheta = np.cos(theta)mid = np.sqrt(1-(n1/n2*np.sin(theta))**2)   #中间变量rp = (n2*xTheta-n1*mid)/(n2*xTheta+n1*mid)  #p分量振幅反射率rs = (n1*xTheta-n2*mid)/(n1*xTheta+n2*mid)  #tp = 2*n1*xTheta/(n2*xTheta+n1*mid)ts = 2*n1*xTheta/(n1*xTheta+n2*mid)return rp, rs, tp, ts#画图
def testFres1(n1=1,n2=1.45):         #默认n2为1.45theta = np.arange(0,90,0.1)+0j  #a = theta*np.pi/180rp,rs,tp,ts = fresnel(theta,n1,n2)fig = plt.figure(1)plt.subplot(1,2,1)plt.plot(theta,rp,'-',label='rp')plt.plot(theta,rs,'-.',label='rs')plt.plot(theta,np.abs(rp),'--',label='|rp|')plt.plot(theta,np.abs(rs),':',label='|rs|')plt.legend()plt.subplot(1,2,2)plt.plot(theta,tp,'-',label='tp')plt.plot(theta,ts,'-.',label='ts')plt.plot(theta,np.abs(tp),'--',label='|tp|')plt.plot(theta,np.abs(ts),':',label='|ts|')plt.legend()plt.show()def testFres2(n1=1,n2=1.5):theta = np.arange(0,90,0.1)+0ja = theta*np.pi/180rp,rs,tp,ts = fresnel(theta,n1,n2)Rp = np.abs(rp)**2Rs = np.abs(rs)**2Rn = (Rp+Rs)/2fig = plt.figure(1)plt.subplot(1,2,1)plt.plot(theta,Rp,'-',label='R_p')#plt.plot(theta,Rs,'-.',label='R_s')plt.plot(theta,Rn,'-',label='R_n')plt.legend()plt.show()def testFres3(n1=1.5,n2=1):theta = np.arange(0,90,0.1)+0ja = theta*np.pi/180rp,rs,tp,ts = fresnel(theta,n1,n2)Rp = np.abs(rp)**2Rs = np.abs(rs)**2Rn = (Rp+Rs)/2fig = plt.figure(2)plt.subplot(1,2,1)plt.plot(theta,Rp,'-',label='R_p')plt.plot(theta,Rs,'-.',label='R_s')plt.plot(theta,Rn,'-',label='R_n')plt.legend()plt.show()def testFres():theta = np.arange(0,90,0.1)+0j  #a = theta*np.pi/180rp,rs,tp,ts = fresnel(theta,1,2)Rp = np.abs(rp)**2Rs = np.abs(rs)**2Rn = (Rp+Rs)/2plt.suptitle("202008010110-homework")plt.subplot(1,2,1)plt.title("n1 = 1, n2 = 2")plt.plot(theta,Rp,'-',label='R_p')plt.plot(theta,Rs,'-',label='R_s')plt.plot(theta,Rn,'-.',label='')plt.ylim(0,1)#y轴上限为1,下限为0def to_percent(temp, position):#百分比上下限return '%1.0f'%(100*temp) + '%'plt.gca().yaxis.set_major_formatter(FuncFormatter(to_percent))plt.legend()        #图例plt.xlabel("Incident angle (θ1/°)")plt.ylabel("Reflectivity (%)")#设置注释plt.annotate('Brewster angle (%.2f)'%(180*np.arctan(2)/np.pi), xy=(180*np.arctan(2)/np.pi, 0), xytext=(35, 0.6),xycoords='data',arrowprops=dict(facecolor='black',arrowstyle = "->",))rp,rs,tp,ts = fresnel(theta,2,1)Rp = np.abs(rp)**2Rs = np.abs(rs)**2Rn = (Rp+Rs)/2plt.subplot(1,2,2)plt.title("n1 = 2, n2 = 1")plt.plot(theta,Rp,'-',label='R_p')plt.plot(theta,Rs,'-',label='R_s')plt.plot(theta,Rn,'-.',label='')plt.ylim(0,1)#上限为1,下限为0def to_percent(temp, position):#百分比上下限return '%1.0f'%(100*temp) + '%'plt.gca().yaxis.set_major_formatter(FuncFormatter(to_percent))plt.legend()        #图例plt.xlabel("Incident angle (θ1/°)")plt.ylabel("Reflectivity (%)")#设置注释plt.annotate('Brewster angle(%.2f)'%(180*np.arctan(0.5)/np.pi), xy=(180*np.arctan(0.5)/np.pi, 0), xytext=(35, 0.6),xycoords='data',arrowprops=dict(facecolor='black',arrowstyle = "->",))plt.annotate('Critical angle(%.2f)'%(180*np.arcsin(0.5)/np.pi), xy=(180*np.arcsin(0.5)/np.pi, 0), xytext=(60, 0.4),xycoords='data',arrowprops=dict(facecolor='black',arrowstyle = "->",))plt.show()#主函数
#testFres2()
#testFres3()
testFres()

(14条消息) python光学仿真之菲涅耳公式_微小冷的博客-CSDN博客_菲涅尔公式

(14条消息) Python学习笔记(4)——Matplotlib中的annotate(注解)的用法_赵赵赵颖的博客-CSDN博客_annotate

光学仿真(python菲涅尔公式)相关推荐

  1. MATLAB:菲涅尔公式(反射/透射公式)

    目录 案例1:光疏到光密介质 案例2:光密到光疏介质 案例1:光疏到光密介质 平面光波从空气(折射率为)入射到石英玻璃中(折射率为),用 MATLAB作出p.s分量的振幅反射率和振幅透射率以及它们的绝 ...

  2. 菲涅尔公式实现边缘光效果

    Shader"review/EdgeEmission" {///标准光照模型 光照数据=自发光(E)+漫反射光(D)+环境光(A)+高光(S)Properties{_MainTex ...

  3. MATLAB利用菲涅尔公式仿真光的折射

    从空气进入石英玻璃,计算振幅反射率.透射率和对应的绝对值: clear; close all;n1 = 1; %空气折射率 n2 = 1.45;%平板玻璃折射率 theta = 0:0.1:90;%角 ...

  4. 菲涅尔公式应用,结合简单的pbr公式,制作水shader

    内容还没完善,有时间会增加反射,各向异性处理等.相互学习. Shader "water/fresnelpbr" { Properties { _MainTex ("Tex ...

  5. 基于Matlab模拟菲涅尔公式

    ✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可私信.

  6. matlab拟合菲涅尔曲面,matlab-对菲涅尔公式画图

    (3)反射系数r,反射率R与入射角x和折射率之比n的关系 clear; clc; clf; [n,zeta1]=meshgrid(0.6:0.05:1.5,0:pi/50:pi/2); zeta2=r ...

  7. 三角公式+菲涅尔公式

  8. 菲涅尔定理及MATLAB实现

    ** 菲涅尔定理及MATLAB实现   本文是学习胡章芳<MATLAB仿真及其在光学课程中的应用>和赵凯华<光学>这两本书时所做笔记. 1. 菲尼尔反射与折射公式   一般来说 ...

  9. Fresnel(菲涅尔)

    背景: 菲涅耳公式用来描述光在不同折射率的介质之间的行为.菲涅尔公式是光学中的重要公式,用它能解释反射光的强度.折射光的强度.相位与入射光的强度的关系. 1. 反射公式: fresnel = fres ...

  10. Physics CG:菲涅尔(fresnel)反射

    这一篇是物理学CG的开篇,其实我多开了一个分类也是心理无奈的,自身水平有限,而很多物理图形学知识积累太少,有些甚至根本没学过.然而高级图形学知识中,或者说高级图形着色效果中,很大一部分是基于" ...

最新文章

  1. 上下位机通讯协议_上位机与下位机的区别通讯
  2. 在WinCE 6.0系统下实现USB功能定制
  3. ap计算机科学a买什么书,准备AP*计算机科学A考试-第1部分
  4. “老年”程序员带你用Python玩街霸,你的童年用编程实现也很简单
  5. Python框架篇之Django(Template模版:标签tag、自定义filter、extend模板继承)
  6. cmd查看所有数据库 db2_db2 cmd命令操作
  7. js当中null和{}区别
  8. 一个开发周期为6个月的中小型软件开发项目成本预算大致表,不足之处请指点...
  9. (二)匈牙利算法简介
  10. python sys.stdin.buffer_为sys.stdin设置较小的缓冲区大小?
  11. 办公自动化系统项目报告
  12. 输入一个正整数数组,把数组里所有数字拼接起来排成一个数,打印能拼接出的所有数字中最小的一个。例如输入数组{3,32,321},则打印出这三个数字能排成的最小数字为321323。剑指Offer(32)
  13. 第三届“马栏山杯” 国际音视频算法大赛
  14. RED5与tomcat整合
  15. 鸿蒙系统8月9日登场,华为自研鸿蒙系统将于8月9日正式登场,还有全新的鸿鹄芯片...
  16. [数据分析] [保姆级教程] 数据差异分析方法
  17. vue.js毕业设计,基于vue.js前后端分离在线教育视频点播小程序系统 开题报告
  18. OBS Studio导播台多画面使用实测
  19. 不动产测绘数据入库_不动产登记中房产与地籍测绘数据整合
  20. docker存储卷的使用

热门文章

  1. 关于全球同服和亚马逊Global Accelerating
  2. matlab矩阵两个乘法运算,MATLAB矩阵运算-乘法
  3. java生成wsdl文件_webservice之通过wsdl文件生成客户端
  4. ftp连接显示被服务器被拒绝,ftp连接显示被服务器被拒绝
  5. 经典数据库sql查询50题
  6. realitycapture 3D建模软件
  7. solidity教程(四)僵尸作战系统
  8. matlab幅度归一化,matlab归一化方法
  9. 输入关键字生成对联_对联生成器在线生成_对联在线自动生成器下载V1.0.0|好特下载...
  10. 到底什么是移动边缘计算?