CST Studio Suite 基础操作实验(静电场)

前言

笔者cst为2022版本,不同版本有略微不同,年份越新功能越强,但实际操作上会有略微不同,安装教程随意找一篇博客照着安装即可

下面是一些相关的cst仿真实验和matlab理论计算对比

文件创建

首先进入CST Studio Suite之中,选择下面的3D Simulation进行仿真文件的创建

本次实验全部都使用这个Low Frequency模型进行仿真

核心步骤

1.转变单位

根据图中位置进行单位转变

2.模型设置

将会在下面具体问题之中展示

3.仿真条件设置

在使用solver之前要先设置好background和boundaries(根据实验具体要求设定),本次实验均为如下参数设置

Background  通常设置成模型大小的2到3倍即可

Boundries

4.仿真Slover选择

根据具体实验选择Slover,本次实验均为静电场

5.仿真数据图像输出

按照下图选中条件

根据测量要求在Browse All界面内选择想要的结果并要注意xyz范围的选择

假如实验要求是看x轴内外的磁感应强度,那就是相当于看xoy面上沿着x轴上的变化 ,那么yz的最小值都应该设置为0,下图x设置为0是因为最后解算出来的图像是关于x轴对称的,为了方便后续matlab理论计算

导出最后的图像数据便于matlab理论计算比较

第一题:

仿真模型:

半径为10mm,介电常数为(1+0.3)的小球均匀分布着1C的电荷,当球心在坐标原点,求x轴上的电场E(x).

首先先建造一个小球,设置半径为20mm

然后修改小球介电常数为1.3,修改Epsilon参数

最后给小球充电,完成模型设置,余下步骤为核心步骤的3,4,5

理论问题:

假设在半径为a的球体内均匀分布着密度为ρ0的电荷,试求任意点的电场强度。

理论公式的推导

使用matlab进行计算和对比

% Parameters
a = 10; % Sphere radius (mm)
Q = 1; % Total charge (C)
epsilon_r = 1.3; % Dielectric constant
epsilon_0 = 8.85e-12; % Vacuum permittivity (F/m)

% Define spatial points (only positive axis)
x = linspace(0, 25, 500); % From 0 mm to 25 mm

% Initialize electric field array
E = zeros(size(x));

% Calculate electric field
for i = 1:length(x)
    r = x(i) * 1e-3; % Convert to meters
    if r < a * 1e-3
        % Inside the sphere
        E(i) = (Q * r) / (4 * pi * epsilon_r * epsilon_0 * (a * 1e-3)^3);
    else
        % Outside the sphere
        E(i) = (Q) / (4 * pi * epsilon_0 * r^2);
    end
end

% Plot computed results
figure;
plot(x, E, 'r-', 'LineWidth', 2); % Red solid line for computed results

% Add title and axis labels
title('Comparison of Electric Field on Positive X-Axis');
xlabel('Position (X) [mm]');
ylabel('E-Field (N/C)');

% Show grid
grid on;

% Adjust axis to fit data range
axis tight;

% Load experimental data
data = load('E1.txt');

% Extract X values and E-Field values
X_exp = data(:, 1); % First column
E_Field_exp = data(:, 2); % Second column

% Plot experimental data
hold on;
plot(X_exp, E_Field_exp, 'b--', 'LineWidth', 2); % Blue dashed line for experimental data
legend('Computed E-Field', 'Experimental E-Field');
hold off;

结果分析和比较

x < 0 的值与 x > 0 的值相同。
我们首先观察计算值和模拟值的 E 分布变化趋势。当 R <= 10mm 时,E 分布呈线性增长。当球体内部的介电常数大于球体外部的介电常数时,图像会突然增大,这从等式的计算中不难理解。
当 R < 10mm 时,计算值与模拟值相吻合。但当 R > 10mm 时,曲线重合度不高,实验结果表明曲线不够平滑。
造成这种差异的原因可能是边界条件。在实验中,我将边界条件设置为 15,这与实际情况相比是比较小的。虽然存在微小误差,但这是可以接受的,因为不可能绝对模拟真实情况。当我将背景设置为 500 时的输出如下,可以很明显地对比原来的 15 看到,500 的采样率更高,曲线更平滑,但它会带来一个严重的问题,就是计算时间太长,设置 500 时的计算时间为 7 分钟。

第二题

仿真模型

位于xoy平面上,半径为10mm,介电常数为1的小圆盘匀分布着(1+0.3)C的电荷,当圆心在坐标原点,求z轴上的电场E(z).

画一个圆盘,直接用圆柱这个绘制即可

调整介电常数为1(与之前操作类似)

上电

在最后数据图像输出的时候要选定沿z轴测量

理论问题:

位于xoy平面上的半径为a、圆心在坐标原点的带电圆盘,面电荷密度为ρS,求z轴上的电场强度.

理论推导

matlab代码

% Parameters
R = 10; % Disk radius (mm)
Q = 1.3; % Total charge on the disk (C)
epsilon_0 = 8.854e-12; % Vacuum permittivity (F/m)

sigma = Q / (pi * (R * 1e-3)^2); % Charge surface density (C/m^2)

% Points on the z-axis
z_values = linspace(0, 15, 500); % Generate 500 z-values from 0 mm to 50 mm

% Initialize electric field array
E_z = zeros(size(z_values));

% Calculate electric field at each z position
for i = 1:length(z_values)
    z = z_values(i) * 1e-3; % Convert to meters
    integrand = @(s) s ./ (z^2 + s.^2).^(3/2);
    integral_result = integral(integrand, 0, R * 1e-3, 'ArrayValued', true);
    E_z(i) = sigma * z / (2 * epsilon_0) * integral_result;
end

% Plot computed results
figure;
plot(z_values, E_z, 'r-', 'LineWidth', 2); % Red solid line for computed results

% Add title and axis labels
title('Comparison of Electric Field on Position Z-Axis');
xlabel('Position (Z) [mm]');
ylabel('E-Field (N/C)');

% Show grid
grid on;

% Adjust axis to fit data range
axis tight;

% Load experimental data
data = load('E2.txt');

% Extract Z values and E-Field values
Z_exp = data(:, 1); % First column
E_Field_exp = data(:, 2); % Second column

% Plot experimental data
hold on;
plot(Z_exp, E_Field_exp, 'b--', 'LineWidth', 2); % Blue dashed line for experimental data
legend('Computed E-Field', 'Experimental E-Field');
hold off;

结果分析和比较

由于对称性,我只显示 z > 0 的范围,z < 0 的值与 z > 0 相同。
我们首先观察计算值和模拟值的 E 分布变化趋势。当 z >= 0mm 时,E 分布通过反比例函数逐渐减小,最后稳定在零附近。从图中可以看出,计算结果和模拟结果基本一致。
 

第三题

仿真模型:

半径为10mm的理想导体小球均匀分布着1C的电荷,球心在坐标原点。外套有半径为(20+0.3*10)mm的相对介电常数为4的同心介质球壳,求x轴上的电场E(x)和电位移矢量D(x).

先建一个大球,再在内部建造一个小球,然后在弹出的窗口中下面这个选项即可实现球壳

也可以勾选None然后再使用modeling栏目Tools里面的Boolean去建造球壳

切换切面视图查看球壳建造

建造完球壳后再在内部建造一个理想导体小球,这个小球材料要选择PEC,并且上电要选择给PEC材料上电,球壳厚度在本个实验中没有太大影响,但建议使用厚度较小的球壳,最后模型如下图所示

介电常数和上电步骤与前面的实验类似

最后一步的数据图像输出要调整测量电位移矢量D(x)

理论问题:

一个半径为a的导体球,带电量为Q,在导体球外套有外半径为b的同心介质球壳,壳外是空气,如图 所示。求空间任一点的DE。

理论推导

matlab代码

% Parameters
R_inner = 10; % Inner radius of the conductor ball (mm)
R_outer = 20 + 0.3 * 10; % Outer radius of the dielectric shell (mm)
Q = 1; % Total charge on the conductor ball (C)
epsilon_r = 4; % Relative permittivity of the dielectric shell
epsilon_0 = 8.85e-12; % Vacuum permittivity (F/m)

% Define spatial points along the x-axis
x = linspace(0, 60, 1000); % From 0 mm to 60 mm

% Initialize electric field and electric displacement field arrays
E = zeros(size(x)); % Electric field array
D = zeros(size(x)); % Electric displacement field array

% Calculate electric field and electric displacement field
for i = 1:length(x)
    r = x(i) * 1e-3; % Convert to meters
    if r <= R_inner * 1e-3 % Inside the conductor ball
        E(i) = 0; % Electric field inside a conductor is zero
        D(i) = 0; % Electric displacement field inside a conductor is zero
    elseif r <= R_outer * 1e-3 % Inside the dielectric shell
        E(i) = Q / (4 * pi * epsilon_0 * epsilon_r * r^2); % Electric field in dielectric shell
        D(i) = Q / (4 * pi * r^2); % Electric displacement field in dielectric shell
    else % Outside the dielectric shell
        E(i) = Q / (4 * pi * epsilon_0 * r^2); % Electric field outside the dielectric shell
        D(i) = Q / (4 * pi * r^2); % Electric displacement field outside the dielectric shell
    end
end

% Convert x to mm for plotting
x_mm = x;

% Plot computed electric field
figure;
plot(x_mm, E, 'r-', 'LineWidth', 2); % Red solid line for computed electric field

% Add title and axis labels
title('E-Field vs Position (X) on X-Axis');
xlabel('Position (X) [mm]');
ylabel('E-Field (N/C)');

% Show grid
grid on;

% Adjust axis to fit data range
axis tight;

% Load experimental data
data = load('E3.txt');

% Extract X values and E-Field values
X_exp = data(:, 1); % First column
E_Field_exp = data(:, 2); % Second column

% Plot experimental data
hold on;
plot(X_exp, E_Field_exp, 'b--', 'LineWidth', 2); % Blue dashed line for experimental data
legend('Computed E-Field', 'Experimental E-Field');
hold off;

% Plot computed electric displacement field
figure;
plot(x_mm, D, 'g-', 'LineWidth', 2); % Green solid line for computed electric displacement field

% Add title and axis labels
title('D-Field vs Position (X) on X-Axis');
xlabel('Position (X) [mm]');
ylabel('D-Field (C/m^2)');

% Show grid
grid on;

% Adjust axis to fit data range
axis tight;

% Load experimental data
data = load('D3.txt');

% Extract X values and D-Field values
X_exp = data(:, 1); % First column
D_Field_exp = data(:, 2); % Second column

% Plot experimental electric field data again for comparison
hold on;
plot(X_exp, D_Field_exp, 'b--', 'LineWidth', 2); % Blue dashed line for experimental electric field
legend('Computed D-Field', 'Experimental D-Field');
hold off;

结果分析和比较

x < 0 的值与 x > 0 的值相同。
我们首先观察 E 分布和 D 分布的计算值和模拟值的变化趋势。对于 E 分布,当 x < 10mm 时,由于内球不带电荷,E 等于 0。当 x = 10mm 时,由于内球表面带电,E 会发生突变。当 10 < x < 20 时,E 按反比例函数逐渐减小。当 x = 23mm 时,由于ε的变化又发生了一次突变,E 增大了约 4 倍。当 x > 23mm 时,E 通过反比例函数逐渐减小,最后稳定在零附近。对于 D 分布,当 x < 10mm 时,由于内球不带电荷,D 等于 0。当 x = 10 时,由于内球表面带电,D 会发生突变。当 x > 10mm 时,D 按反比例函数逐渐减小,最后趋近于零。值得注意的是,D 与ε无关,因此在 x = 23mm 时可能不会发生变化。
我们注意到,当 x = 10mm 时,计算与模拟存在一定误差。对于 x = 10mm 时的误差,一个可能的原因是球体的材料。在实验中,我们使用 PEC 作为导体球,但在现实世界中,材料不可能那么完美。总之,避免这种微小的误差是不可避免的,这也是可以接受的。

第四题

仿真模型:

同心球电容器的内导体半径为10mm,外导体的内半径为20mm,其间填充两种介质,上半部分的相对介电常数为(2+0.3),下半部分的相对介电常数为4,设内、外导体带电分别为1C和-1C,求x轴上的电场E(x)和电位移矢量D(x).(x轴经过两个介质半球的顶点与同心球的球心,指向介电常数较小的半球)

最后建模出来的图形大致为此

这个实验重点在于调整坐标轴对应关系,右下角为对应的xyz参考坐标轴,要把中心的uwv旋转到对应位置再进行uv平面切割才能实现(暂时没找到更简易的操作,故使用了这个较为繁琐的过程)

调整中心坐标轴指向便于后续切割

沿着uv平面切割

内导体外导体都选择使用PEC材料,中间介质使用normal材料,介电常数设置和上电过程略

理论问题:

同心球电容器的内导体半径为a,外导体的内半径为b,其间填充两种介质,上半部分的介电常数为ε1,下半部分的介电常数为ε2,如图 所示。设内、外导体带电分别为q和-q,求各部分的电位移矢量和电场强度。

理论推导

matlab代码

% Parameters
R_inner = 10; % Inner radius of the inner conductor (mm)
R_outer = 20; % Inner radius of the outer conductor (mm)
Q_inner = 1; % Charge on the inner conductor (C)
Q_outer = -1; % Charge on the outer conductor (C)
epsilon_r1 = 2 + 0.3; % Relative permittivity of the upper half (unitless)
epsilon_r2 = 4; % Relative permittivity of the lower half (unitless)
epsilon_0 = 8.854e-12; % Vacuum permittivity (F/m)

% Define spatial points along the x-axis
x = linspace(-50, 50, 1000); % From -50 mm to 50 mm

% Initialize electric field and electric displacement field arrays
E = zeros(size(x)); % Electric field array
D = zeros(size(x)); % Electric displacement field array

% Calculate electric field and electric displacement field
for i = 1:length(x)
    r = abs(x(i)) * 1e-3; % Convert to meters
    if r <= R_inner * 1e-3 % Inside the inner conductor
        E(i) = 0; % Electric field inside a conductor is zero
        D(i) = 0; % Electric displacement field inside a conductor is zero
    elseif r <= R_outer * 1e-3 % Between inner and outer conductor
        if x(i) >= 0 % Upper half
            epsilon_r = epsilon_r1;
        else % Lower half
            epsilon_r = epsilon_r2;
        end
        E(i) = Q_inner / (2 * pi * epsilon_0 * (epsilon_r1 + epsilon_r2) * r^2*1e+6); % Electric field in dielectric shell
        D(i) = epsilon_0 * epsilon_r * E(i); % Electric displacement field in dielectric shell
    else % Beyond the outer conductor
        E(i) = 0; % Electric field outside the outer conductor is zero
        D(i) = 0; % Electric displacement field outside the outer conductor is zero
    end
end

% Convert x to mm for plotting
x_mm = x;

% Plot computed electric field
figure;
plot(x, E, 'r-', 'LineWidth', 2); % Red solid line for computed electric field

% Add title and axis labels
title('E-Field vs Position (X) on X-Axis');
xlabel('Position (X) [mm]');
ylabel('E-Field (N/C)');

% Show grid
grid on;

% Adjust axis to fit data range
axis tight;

% Load experimental electric field data
data_E =  readmatrix("E:\Homework\E4.txt"); % Use load to read the data

% Extract X values and E-Field values
X_exp_E = data_E(:, 1); % First column
E_Field_exp = data_E(:, 2); % Second column

% Plot experimental electric field data
hold on;
plot(X_exp_E, E_Field_exp, 'b--', 'LineWidth', 2); % Blue dashed line for experimental electric field
legend('Computed E-Field', 'Experimental E-Field');
hold off;

% Plot computed electric displacement field
figure;
plot(x_mm, D, 'g-', 'LineWidth', 2); % Green solid line for computed electric displacement field

% Add title and axis labels
title('D-Field vs Position (X) on X-Axis');
xlabel('Position (X) [mm]');
ylabel('D-Field (C/m^2)');

% Show grid
grid on;

% Adjust axis to fit data range
axis tight;

% Load experimental electric displacement field data
data_D =  readmatrix("E:\Homework\D4.txt"); % Use load to read the data

% Extract X values and D-Field values
X_exp_D = data_D(:, 1); % First column
D_Field_exp = data_D(:, 2); % Second column

% Plot experimental electric displacement field data
hold on;
plot(X_exp_D, D_Field_exp, 'b--', 'LineWidth', 2); % Blue dashed line for experimental electric displacement field
legend('Computed D-Field', 'Experimental D-Field');
hold off;

结果分析和比较

由于在 x = 0mm 附近的 E 分布和 D 分布可能存在差异,因此我绘制了整个 x 轴的 E 分布和 D 分布图。我们首先观察 E 分布和 D 分布的计算值和模拟值的变化趋势。对于 E 分布,根据 E 定理的边界条件,E 与 x = 0mm 对称,因此我们只观察 x > 0mm 的范围。当 0 < x < 10mm 时,由于内球中没有自由电荷,所以 E 等于 0。当 x = 10mm 时,由于内球表面的变化,E 发生了突变。当 10 < x < 20 时,E 按反比例函数逐渐减小。当 x = 20mm 时,E 等于 0,因为传导球隔离了外部区域。对于 D 分布,当 x < -20 时,由于导静电球体隔离了外部区域,因此 D 等于 0。当 x = -20mm 时,由于内球的表面电荷会发生突变。当 -20 < x < -10 时,D 按反比例函数增加。当 -10 <= x <= 10mm 时,由于导体球的特性,D 等于 0。当 x = 10mm 时,由于内球的表面电荷,D 又发生了变化。当 10 < x <= 20mm 时,D 按反比例函数减小。当 x > 20mm 时,由于外导电球隔离了外部区域,D 等于 0。值得注意的是,当 -20 < x < -10 和 10 < x < 20 时,由于这两个特定区域的ε不同,所以变化幅度也不同。

我发现,当 x = -10mm 和 x = 10mm 时,计算结果与模拟结果存在一定误差。当 x = -10 和 x = 10mm 时,它穿过导体球的外壳,而导体球的材料是理想的 PEC,这可能与实际情况不同,因此可能会造成这种误差,不过,这种微小的误差是可以接受的。

第五题

仿真模型:

半径分别为20mm、8mm, 对应球心坐标分别为(0,0,0)和(10mm,0,0)的两个球面间有1C均匀体电荷分布,求x轴上[2mm,18mm]的电场E(x).

最后模型图如下所示(过程略)

理论问题:

半径分别为a、b(a>b),球心距为c(c<a-b)的两个球面间有密度为ρ的均匀体电荷分布,求半径为b的球面内任意一点的电场强度。设c沿着x轴正方向。

理论推导

matlab代码

% Constants
epsilon_0 = 8.854e-12; % Permittivity of vacuum (C/V·m)
r_outer = 20e-3; % Radius of the outer sphere (20 mm)
r_inner = 8e-3; % Radius of the inner sphere (8 mm)
c = 10e-3; % Distance between the centers of the spheres (10 mm)
Q = 1; % Total charge (C)

% Calculate the volume of the spherical shell
V = (4/3) * pi * (r_outer^3 - r_inner^3);

% Calculate volume charge density
rho = Q / V;

% Define spatial points along the x-axis from 2 mm to 18 mm
x = linspace(2e-3, 18e-3, 10000); % From 2 mm to 18 mm

% Theoretical calculation of the electric field inside the cavity
E = (rho * c) / (3 * epsilon_0) * ones(size(x));

% Convert x to mm for plotting
x_mm = x * 1e3;

% Plot computed electric field
figure;
plot(x_mm, E, 'r-', 'LineWidth', 2); % Red solid line for computed electric field

% Add title and axis labels
title('E-Field vs Position (X) on X-Axis');
xlabel('Position (X) [mm]');
ylabel('E-Field (N/C)');

% Show grid
grid on;

% Adjust axis to fit data range
axis tight;

% Load experimental electric field data
data_E = load('E5.txt'); % Use load to read the data

% Extract X values and E-Field values
X_exp_E = data_E(:, 1); % First column
E_Field_exp = data_E(:, 2); % Second column

% Plot experimental electric field data
hold on;
plot(X_exp_E, E_Field_exp, 'b--', 'LineWidth', 2); % Blue dashed line for experimental electric field
legend('Computed E-Field', 'Experimental E-Field');
hold off;

结果分析和比较

计算结果证实,E 是一个恒定值。然而,根据模拟结果,在 2 毫米到 18 毫米的范围内,E 的实验值是波动的。从总体结果可以看出,实验图和计算图的形状相似,但实验图中的数值却在波动。这可能与实验过程中选择的背景值过小,导致最终实验的采样点较少有关。实验得到的曲线并不平滑,而是锯齿状的,这也是之前所有实验中都存在的问题。一般来说,将背景设置为图形大小的两倍左右即可。设置过大的背景可以产生平滑的曲线,但会导致大量的计算开销。

  • 19
    点赞
  • 31
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值