物理类-一维光子晶体反射率以及透射率

虽然可能但是matlab、mathmatica更好用,少掉点头发还是用了python。

一维也算是比较简单了,我看很多哥哥们都喜欢收费,我想了想肯定是免费。


这里设置了一个函数,Film(),在前面自己改一下波长lam还有一些个initial condition

​
import numpy as np
from matplotlib import pyplot as plt


class Film():
    def __init__(self, n_list, d_list, labels=None, nd=True, lambda0=550):
        self.n_list = n_list
        self.nd = nd
        self.lambda0 = lambda0
        self.d_list = d_list
        self.labels = labels
    
    
    def __part_fit(self, rect_list, theta_cos, n_list, j):
        rect_list = np.array(rect_list, dtype=np.complex128)
        rect_list = rect_list.transpose(3, 0, 1, 2)
        n_theta_cos = n_list[j][-1] * theta_cos
        Y = []
        for i in range(rect_list.shape[0]):
            rect = np.eye(2)
            for k in range(rect_list[i].shape[0]):
                rect = np.dot(rect, rect_list[i, k])
            rect = np.dot(rect, np.array([[1], [n_theta_cos[i]]]))
            Y.append(rect)
        Y = np.array(Y)
        Y = Y[:, 1, 0] / Y[:, 0, 0]
        return Y
    
    
    def fit(self, wavelength, theta=0):
        if type(wavelength) == float or type(wavelength) == int:
            wavelength = [wavelength]
        self.wavelength = np.array(wavelength)
        
        n_list = []
        n_lambda0 = []
        for i in self.n_list:
            n_list.append([])
            n_lambda0.append([])
            for j in i:
                if type(j).__name__ != 'function':
                    n_list
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值