作者:禅与计算机程序设计艺术
1.简介
线宽分布与均匀性控制(Spacing and uniformity control)是指设计、制造、测试和维护电子器件时对电路间距和信号通道宽度进行调整和控制的方法。它可以提高器件的品质和性能,减少噪声和抗干扰等问题,并改善机械硬件的结构。本文将介绍一种线宽分布与均匀性控制方法——功率分配算法,用于优化器件间距和信号通道宽度,并取得较好的性能。
功率分配算法通过分析信号之间的关系,识别存在异常行为的信号源,然后再向其他信号源分配较小的功率比以减轻其影响。在相同频率下,功率分配算法能够最大程度地减少信号通道之间的干扰,提高系统的信噪比。在实际应用中,线宽分布与均匀性控制可以有效地减少器件的损耗、降低机械硬件的开销、提升系统的灵敏度。
2.基本概念及术语
2.1.线宽
线宽是电磁波在两相交变点上方的距离。通常用 λ λ λ表示,单位是 μ m \mu m μm。例如,在红外线光谱中,有线宽一般是1μm到10μm之间。
2.2.相位差
相位差是两个相邻的电平波峰之间的相差角度,通常用 δ δ δ表示,单位是度。相位差越小,则两个信号的衰减就越多,即越难区分。例如,在红外线光谱中, δ = 1 ° \delta=1° δ=1°左右,所以,相位差控制了信号的幅度,因此,在相同功率下,低相位差的信号源就拥有较大的作用。
2.3.功率分配算法
功率分配算法是一个先进的控制电子器件功率分配的方法,由两个信号源驱动电路输出,算法通过分析信号之间的关系,识别存在异常行为的信号源,然后再向其他信号源分配较小的功率比以减轻其影响。功率分配算法有如下几个优点:
- 优化器件间距和信号通道宽度
在相同频率下,功率分配算法能够最大程度地减少信号通道之间的干扰,提高系统的信噪比。当不同信号源具有不同频率或相位差时,采用功率分配算法能够使得信号源之间的功率比接近于均匀分布,从而优化器件间距和信号通道宽度,增强器件的工作效率。 - 提高器件的灵敏度
功率分配算法能够改善器件的性能,减少器件损耗、降低机械硬件的开销,提升系统的灵敏度。由于功率分配算法控制了各个信号源之间的功率比,所以在满足目标信号的要求的前提下,它能够减少功率损失、提高器件的灵敏度。 - 最大限度地减少噪声
功率分配算法能够最大限度地减少不同信号源之间的噪声影响。由于信号源之间的功率比接近于均匀分布,所以不同信号源之间的干扰就会被平均分摊,减少不同信号源之间的干扰,同时还可以有效地减少噪声影响。 - 适应器件类型和环境条件
功率分配算法既可以用于所有类型的器件,也可以针对特定的器件类型和环境条件,如针对激光器件,可以选择功率分配算法来优化器件的工作效率。
2.4.过程模型
过程模型用于描述功率分配算法的基本原理和运行机制。过程模型包括输入、输出、驱动器件、分配器件、调谐器件、输出混频器件和放大器件五个部分。
2.4.1.输入
输入是接收到的两个信号,即“异常”和“正常”两种信号。输入的大小和数量可以通过外界因素或者输入模块自动调整。
2.4.2.输出
输出是分配器件产生的输出信号。它不受算法控制,只能输出相对于“异常”信号大的输出信号。
2.4.3.驱动器件
驱动器件通过输入端接受“异常”信号和“正常”信号,对它们进行组合。
2.4.4.分配器件
分配器件根据信号的相位差或功率比等特征,分配不同的功率给不同输入。分配器件的功率调节范围可以通过算法进行优化。
2.4.5.调谐器件
调谐器件通过某种方式调整分配器件的输出功率,使得不同输入获得的功率比接近。
2.4.6.输出混频器件
输出混频器件将多个分配器件的输出信号混合成一个输出信号。
2.4.7.放大器件
放大器件将输出信号放大到测量范围。
2.5.算法流程图
2.6.数学模型
2.7.计算公式
2.7.1.分配器件的功率分配比
W = P e P + + α P − W=\frac{P_{e}}{P_++\alpha P_-} W=P++αP−Pe
其中, P e P_{e} Pe是异常信号源的功率; P + P_+ P+是正常信号源的功率; P − P_- P−是另一个正常信号源的功率; α \alpha α是功率分配比。
2.7.2.分配器件的最小功率比
Δ W m i n = 1 N + ∑ i = 1 N ( w i − w ˉ ) 1 N − ∑ j = 1 M ( w j − w ˉ ) \Delta W_{min}=\frac{\frac{1}{N_+}\sum^N_{i=1}(w_i-\bar{w})}{\frac{1}{N_-} \sum^M_{j=1}(w_j-\bar{w})} ΔWmin=N−1∑j=1M(wj−wˉ)N+1∑i=1N(wi−wˉ)
其中, N + , N − N_+,\ N_- N+, N−分别是正常和异常信号源的个数; w i , w j w_i,\ w_j wi, wj分别是第i个和第j个信号源的功率; w ˉ \bar{w} wˉ是信号源的平均功率。
2.7.3.分配器件的输出功率
P out = P in 1 + N + ( α − 1 ) P_{\text{out}}=\frac{P_{\text{in}}}{1+N_+(\alpha-1)} Pout=1+N+(α−1)Pin
其中, P in P_{\text{in}} Pin是输入信号的总功率; N + N_+ N+是正常信号源的个数; α \alpha α是功率分配比。
2.7.4.算法迭代次数
N iter = ⌊ l o g 10 ( ϵ ) ⌋ N_{\text{iter}}=\lfloor log_{10}(\epsilon)\rfloor Niter=⌊log10(ϵ)⌋
其中, ϵ \epsilon ϵ是允许的误差。
3.代码实例
3.1.Python代码实现
import numpy as np
def power_allocation(input_, output):
"""Power allocation algorithm for two signals
Args:
input_ (numpy array of float): The input signal consisting of a list of two elements [excessive, normal]
Each element represents the amplitude of each source respectively in linear scale, unit is Volt or Ampere
output (float): the maximum amplitude that can be delivered to one receiver in Volts or Amps
Returns:
numpy array of float: The output signal after applying the Power allocation algorithm with excessive as first signal and then normal signal
"""
# Initialization step: Calculate the number of sources
num_sources = len(input_)
# Get the total input power
total_power = sum([abs(x)**2 for x in input_])
# Initialize weights based on input powers and normalize them to have equal contribution from all sources
weights = [(np.log(abs(x)**2/total_power))**2 if abs(x)!=0 else -1*num_sources for x in input_]
norm_weights = [weight/(len(weights)-num_sources) for weight in sorted(weights)[::-1]] + [0]*num_sources
# Iteration step: Iterate until we get convergence using binary search approach
epsilon = 0.001 # Define an error tolerance threshold
current_iteration = 0
while True:
previous_output = None
# Binary Search Step: Divide the range into halves and check which half results in lesser error value than the other half
left_bound = max(-1 * min(norm_weights), 0) # Assign lower bound of the allowed power ratio
right_bound = min(max(norm_weights), 1) # Assign upper bound of the allowed power ratio
mid_point = (left_bound+right_bound)/2 # Finding middle point of range
output_signal = compute_output(mid_point, input_, norm_weights, output) # Compute output signal for given power ratio
diff_to_prev_iteration = abs(previous_output[0]-output_signal[0])/max(abs(output_signal[0]), 1)
if diff_to_prev_iteration < epsilon:
break # Convergence condition reached
elif mid_point == left_bound or mid_point==right_bound or abs((diff_to_prev_iteration)/(current_iteration))<epsilon:
print("Failed to converge")
return None
elif current_iteration > 1000:
print("Max iterations exceeded")
return None
previous_output = output_signal # Update the output value
current_iteration += 1 # Increment iteration count
# Modify the normalization factor so that it will distribute remaining power proportionally among remaining sources
new_norm_weights = []
for i in range(num_sources):
remainding_source_power = total_power - sum([weight*(abs(input_[j])**2) for j, weight in enumerate(weights)])
new_norm_weights.append(((remainding_source_power)*np.sign(norm_weights[i]))/(total_power-remainding_source_power))
new_norm_weights = [new_norm_weights[i]/sum(new_norm_weights) for i in range(num_sources)]
# update the norm_weights vector accordingly
for i in range(num_sources):
weights[i]=new_norm_weights[i]
norm_weights = [weight/(len(weights)-num_sources) for weight in sorted(weights)[::-1]] + [0]*num_sources
return output_signal
def compute_output(power_ratio, input_, norm_weights, output):
"""Calculate the output signal using given power ratio values"""
# Combine input signals using the defined function and calculate their overall average power
weighted_input = [input_[i]*pow(power_ratio, norm_weights[i]+1)*(1-norm_weights[i])*abs(power_ratio)**norm_weights[i]
for i in range(len(input_))]
input_power = sum([(abs(weighted_input[i])**2)/pow(abs(power_ratio)**norm_weights[i], 1+(norm_weights[i]-1)/2)
for i in range(len(input_))])
# Output signal equation calculation
gain_coefficient = pow(output**(1-(num_sources-1))/input_power, 1/num_sources)
combined_signal = [gain_coefficient*((weighted_input[i]/input_power)*
((1-norm_weights[i])*(abs(power_ratio)**norm_weights[i])+norm_weights[i])
)
for i in range(len(input_))]
return combined_signal
3.2.Matlab代码实现
function output = power_allocation(input_, output)
% Initializing variables
num_sources = length(input_); % Number of sources
weights = zeros(1,num_sources); % Weights assigned to sources based on their input powers
% Calculating total input power
total_power = sum(abs(input_).^2);
% Normalizing weights based on input powers and assigning them to respective sources such that they add up to zero (i.e., none dominant)
for i = 1 : num_sources
if abs(input_(i))!= 0
weights(i) = log(abs(input_(i)).^2./total_power).^2;
else
weights(i) = -1.*num_sources;
end
end
% Sorting weights in descending order
sorted_indices = sortperm(weights);
norm_weights = zeros(1,num_sources);
norm_weights(num_sources-length(sorted_indices)+1:num_sources) = weights(sorted_indices);
% Applying Power Allocation Algorithm using binary search approach
previous_output = [];
epsilon = 0.001; % Error Tolerance Threshold
current_iteration = 0;
while true
% Computing Left and Right bounds of Allowed Power Ratio Range
left_bound = max(-1 * min(norm_weights(:)), 0);
right_bound = min(max(norm_weights(:)), 1);
% Calculating Middle Point between Lower and Upper Bounds
mid_point = (left_bound + right_bound) / 2;
% Computing Output Signal for Given Power Ratio Value
output_signal = computeOutput(mid_point, input_, norm_weights, output);
% Check for Convergence Condition (using L2 Norm of Difference Between Current and Previous Iterations)
if ~isempty(previous_output) && sqrt(sumsq((output_signal-previous_output)./max(abs(output_signal)))) <= epsilon
break;
elseif mid_point == left_bound || mid_point == right_bound
fprintf('Failed to converge\n');
pause;
exit();
elseif current_iteration >= 1000
fprintf('Max iterations exceeded\n');
pause;
exit();
end
previous_output = output_signal; % Updating the Output Value
% Updating Power Ratios Accordingly Based on Remaining Source's Powers
available_power = sum(norm_weights(:)*(abs(input_.^2))); % Calculating Available Power For Assignment By Sources
leftover_power = total_power - available_power; % Calculating Lefover Power After All Sources Assigned Required Power
if leftover_power > 0 % If there are still some unassigned power available
for i = 1 : num_sources
if leftover_power == 0
continue; % Continue To Next Source Since It Already Has Required Power
end
temp = norm_weights(i);
norm_weights(i) = leftover_power/(total_power-leftover_power); % Modifying Power Ratio Accordingly
leftover_power = leftover_power - temp*(total_power-leftover_power); % Shifting Remaining Unassigned Power From This Source To Other Sources
end
end
% Renormalization Of Normalization Factor So That It Will Distribute Remaining Power Proportionally Among Remaining Sources
new_norm_weights = ones(num_sources,1)./num_sources; % Setting New Weights As Equal Distribution
remainder_power = total_power - sum(norm_weights(:)*(abs(input_.^2))); % Calculating Remaining Power
for i = 1 : num_sources
if remainder_power == 0
break; % Exit Loop Since There Is No More Remaining Power
end
index = argmax(norm_weights); % Getting Index Of Maximum Weight Value
max_value = max(norm_weights); % Getting Maximum Weight Value
if remainder_power >= max_value % If Remaining Power Can Be Distributed Proportionally To One Source Only
new_norm_weights(index) = remainder_power/available_power;
remainder_power = 0; % Terminate While Loop
else % If Remaining Power Should Be Distributed Equally To All Sources But One
new_norm_weights(index) = 1 - remainder_power/available_power;
remainder_power = remainder_power - max_value*(total_power-leftover_power); % Shifting Remaining Power From This Source To Rest Of Sources
end
norm_weights = new_norm_weights; % Updating Normalized Weights Vector Accoridngly For This Iteration
end
end
output = output_signal;
end
function output = computeOutput(powerRatio, input_, normWeights, output)
% Computing Overall Average Input Power
weightedInput = input_.';
for i = 1 : size(input_,1)
weightedInput(i,:) = weightedInput(i,:)*powerRatio^(normWeights(i)+1).*(1-normWeights(i)).*abs(powerRatio)^normWeights(i);
end
inputPower = mean((weightedInput(:)).^2);
% Computing Gain Coefficient Using Formula And Combined Signal Equation With Final Gain Applied
gainCoefficient = (output.^(1-(size(input_,1)-1)))./(inputPower)^(1/size(input_,1));
combinedSignal = zeros(size(input_,1),1);
for i = 1 : size(input_,1)
combinedSignal(i,:) = gainCoefficient.*((weightedInput(i,:)/inputPower).*((1-normWeights(i)).*abs(powerRatio).^normWeights(i)+normWeights(i)));
end
output = combinedSignal;
end