0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

電験三種Pythonコード

Posted at

電線実長
L(S,D)=S+(8D^2)/(3S)


import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

def wire_length(S, D):
    return S + (8 * D**2) / (3 * S)

# S の値の範囲を設定
S_values = np.linspace(1, 10, 50)  # S の値を 1 から 10 まで 50 点で分割

# D の値の範囲を設定
D_values = np.linspace(1, 10, 50)  # D の値を 1 から 10 まで 50 点で分割

# S_values と D_values を組み合わせてグリッドを作成
S, D = np.meshgrid(S_values, D_values)

# 対応する L(S, D) の値を計算
L = wire_length(S, D)

# 3D プロットの準備
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

# プロット
ax.plot_surface(S, D, L, cmap='viridis')

# 軸ラベルの設定
ax.set_xlabel('S')
ax.set_ylabel('D')
ax.set_zlabel('L(S, D)')

# グラフを表示
plt.show()

電線たるみ
D(S,T)=W(S^2)/(8T) 

import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

def sag(S, T, W):
    return W * (S**2) / (8 * T)

# S の値の範囲を設定
S_values = np.linspace(1, 10, 50)  # S の値を 1 から 10 まで 50 点で分割

# T の値の範囲を設定
T_values = np.linspace(1, 10, 50)  # T の値を 1 から 10 まで 50 点で分割

# S_values と T_values を組み合わせてグリッドを作成
S, T = np.meshgrid(S_values, T_values)

# 対応する D(S, T) の値を計算
# ここでは仮に W = 1 としていますが、W の値は実際の問題に応じて適切な値を設定する必要があります
W = 1  # 適切な値に置き換えることが必要
D = sag(S, T, W)

# 3D プロットの準備
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

# プロット
ax.plot_surface(S, T, D, cmap='viridis')

# 軸ラベルの設定
ax.set_xlabel('S')
ax.set_ylabel('T')
ax.set_zlabel('D(S, T)')

# グラフを表示
plt.show()


作用インダクタンス


import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

def cable_length(D, r):
    return 0.05 + 0.4605 * np.log10(D / r)

# D の値の範囲を設定
D_values = np.linspace(1, 10, 50)  # D の値を 1 から 10 まで 50 点で分割

# r の値の範囲を設定
r_values = np.linspace(0.1, 1, 50)  # r の値を 0.1 から 1 まで 50 点で分割

# D_values と r_values を組み合わせてグリッドを作成
D, r = np.meshgrid(D_values, r_values)

# 対応する L(D, r) の値を計算
L = cable_length(D, r)

# 3D プロットの準備
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

# プロット
ax.plot_surface(D, r, L, cmap='viridis')

# 軸ラベルの設定
ax.set_xlabel('D')
ax.set_ylabel('r')
ax.set_zlabel('L(D, r)')

# グラフを表示
plt.show()

作用静電容量


import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

# 関数 C(D, r) の定義
def C(D, r):
    return 0.02413 / np.log10(D / r)

# Dとrの値の範囲を設定
D_values = np.linspace(0.1, 10, 100)  # Dを0.1から10まで100点で分割
r_values = np.linspace(0.1, 10, 100)  # rを0.1から10まで100点で分割

# Dとrのメッシュグリッドを作成
D, r = np.meshgrid(D_values, r_values)

# 各組み合わせのC(D, r)の値を計算
C_values = C(D, r)

# 3次元プロットを作成
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.plot_surface(D, r, C_values, cmap='viridis')

# 軸ラベルとタイトルを設定
ax.set_xlabel('D')
ax.set_ylabel('r')
ax.set_zlabel('C(D, r)')
ax.set_title('C(D, r)の3次元プロット')

# プロットを表示
plt.show()

直流電動機


import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

# 定数の値を設定
constant = 1.0  # 任意の定数の値(適切な値に置き換えてください)

# ΦとIの範囲を設定
Phi_values = np.linspace(0, 1, 100)  # Φの範囲を適切に設定してください
I_values = np.linspace(0, 1, 100)  # Iの範囲を適切に設定してください

# ΦとIのメッシュグリッドを作成
Phi, I = np.meshgrid(Phi_values, I_values)

# T(Φ, I)の値を計算
T = constant * Phi * I

# Eの範囲を設定
N_values = np.linspace(0, 1000, 100)  # Nの範囲を適切に設定してください

# ΦとNのメッシュグリッドを作成
Phi_2, N = np.meshgrid(Phi_values, N_values)

# Eの値を計算
E = constant * Phi_2 * N

# T(Φ, I)の3Dプロット
fig = plt.figure(figsize=(10, 8))
ax1 = fig.add_subplot(211, projection='3d')
ax1.plot_surface(Phi, I, T, cmap='viridis')
ax1.set_xlabel('Φ')
ax1.set_ylabel('I')
ax1.set_zlabel('T(Φ, I)')
ax1.set_title('T(Φ, I) Surface Plot')

# Eの3Dプロット
ax2 = fig.add_subplot(212, projection='3d')
ax2.plot_surface(Phi_2, N, E, cmap='viridis')
ax2.set_xlabel('Φ')
ax2.set_ylabel('N')
ax2.set_zlabel('E')
ax2.set_title('E Surface Plot')

plt.tight_layout()
plt.show()

import numpy as np
import matplotlib.pyplot as plt

# 慣性モーメント J(kg・m^2)
J = 0.5

# 角速度 N(rpm)
# 例として、0から1000rpmの範囲でプロットする
N_values = np.linspace(0, 1000, 100)  # 0から1000rpmの範囲で100個の値を生成

# 運動エネルギー W の計算
W_values = 0.5 * J * (2 * np.pi * N_values / 60)**2

# プロット
plt.plot(N_values, W_values)
plt.title('Rotational Kinetic Energy')
plt.xlabel('Angular Velocity (rpm)')
plt.ylabel('Kinetic Energy (Joules)')
plt.grid(True)
plt.show()


回転速度
N(f)=120f/p
ω(f)=4πf/p
滑り
s(N)=(N-n)/N

import numpy as np
import matplotlib.pyplot as plt

# パラメータ
p = 4  # ポール数
n = 5  # 同期速度

# 関数定義
def N(f):
    return (120 * f) / p

def omega(f):
    return (4 * np.pi * f) / p

def slip(N):
    return (N - n) / N

# プロットする周波数の範囲
f_values = np.linspace(0, 100, 1000)  # 0から100までの周波数を等間隔にサンプリング

# 回転速度と滑りの計算
N_values = N(f_values)
s_values = slip(N_values)

# グラフのプロット
plt.figure(figsize=(10, 6))
plt.plot(f_values, s_values, label='Slip (s)')
plt.xlabel('Frequency (f)')
plt.ylabel('Slip (s)')
plt.title('Slip vs Frequency')
plt.axhline(y=0, color='black', linewidth=0.8, linestyle='--')  # 滑り0のラインを引く
plt.axvline(x=n * p / 120, color='red', linewidth=0.8, linestyle='--', label='Synchronous Speed')  # 同期速度を示すラインを引く
plt.legend()
plt.grid(True)
plt.show()


ベルヌーイの公式
H(v,p)=(v^2)/(2g)+p/(ρg)


import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

def bernoulli_energy(v, p, g=9.81, rho=1000):
    """
    Calculate Bernoulli's energy for given fluid velocity (v) and pressure (p).

    Parameters:
        v (float or numpy.ndarray): Fluid velocity in m/s.
        p (float or numpy.ndarray): Pressure in Pa.
        g (float, optional): Acceleration due to gravity in m/s^2. Default is Earth's gravity (9.81 m/s^2).
        rho (float, optional): Fluid density in kg/m^3. Default is water density (1000 kg/m^3).

    Returns:
        numpy.ndarray: Bernoulli's energy in J/kg.
    """
    kinetic_energy = (v**2) / (2 * g)
    potential_energy = p / (rho * g)
    return kinetic_energy + potential_energy

# Define the range of fluid velocity (v) and pressure (p)
v_range = np.linspace(0.1, 10, 100)  # Velocity from 0.1 m/s to 10 m/s with 100 points
p_range = np.linspace(1000, 5000, 100)  # Pressure from 1000 Pa to 5000 Pa with 100 points

# Create a meshgrid for v and p
v_mesh, p_mesh = np.meshgrid(v_range, p_range)

# Calculate Bernoulli's energy for the meshgrid
energy_mesh = bernoulli_energy(v_mesh, p_mesh)

# Create a 3D plot
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

# Plot the surface
surf = ax.plot_surface(v_mesh, p_mesh, energy_mesh, cmap='viridis')

# Set axis labels
ax.set_xlabel('Fluid Velocity (m/s)')
ax.set_ylabel('Pressure (Pa)')
ax.set_zlabel("Bernoulli's Energy (J/kg)")

# Add color bar
fig.colorbar(surf, label="Bernoulli's Energy (J/kg)")

# Show the plot
plt.show()



電動機トルク
P(N,T)=(2πN/60)T

 import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

def calculate_power(N, T):
    """
    Calculate the motor power based on angular velocity (N) and torque (T).

    Parameters:
        N (float or numpy.ndarray): Angular velocity in RPM (revolutions per minute).
        T (float or numpy.ndarray): Torque in Nm (Newton meters).

    Returns:
        numpy.ndarray: Power output calculated using the given formula.
    """
    # Convert angular velocity from RPM to radians per second
    omega = (2 * np.pi * N) / 60
    
    # Calculate power output using the formula P = omega * T
    power = omega * T
    return power

# Define ranges for angular velocity (N) and torque (T)
N_range = np.linspace(1000, 3000, 100)  # Angular velocity range in RPM
T_range = np.linspace(100, 500, 100)  # Torque range in Nm

# Create meshgrid for N and T
N_mesh, T_mesh = np.meshgrid(N_range, T_range)

# Calculate power output for the meshgrid
power_mesh = calculate_power(N_mesh, T_mesh)

# Create a 3D plot
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

# Plot the surface
surf = ax.plot_surface(N_mesh, T_mesh, power_mesh, cmap='viridis')

# Set axis labels
ax.set_xlabel('Angular Velocity (RPM)')
ax.set_ylabel('Torque (Nm)')
ax.set_zlabel('Power Output (W)')
ax.set_title('Motor Power Output')

# Add color bar
fig.colorbar(surf, label='Power Output (W)')

# Show the plot
plt.show()


慣性モーメントの運動エネルギー
E(G,N)=((π^2)/(1800))×G×(R×N)^2


import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

# 定数Rの値
R = 1.0  # 例としてRを1とします

# GとNの範囲を設定
G_range = np.linspace(0, 10, 100)  # Gの値の範囲
N_range = np.linspace(0, 10, 100)  # Nの値の範囲

# GとNの値の組み合わせを生成
G, N = np.meshgrid(G_range, N_range)

# E(G,N)の計算
E = (np.pi**2 / 1800) * G * (R * N)**2

# 3次元プロット
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.plot_surface(G, N, E, cmap='viridis')

# 軸ラベルの設定
ax.set_xlabel('G')
ax.set_ylabel('N')
ax.set_zlabel('E(G,N)')

# グラフの表示
plt.show()

電動機トルク
P(N,T)=(2πN/60)T


 import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

def calculate_power(N, T):
    """
    Calculate the motor power based on angular velocity (N) and torque (T).

    Parameters:
        N (float or numpy.ndarray): Angular velocity in RPM (revolutions per minute).
        T (float or numpy.ndarray): Torque in Nm (Newton meters).

    Returns:
        numpy.ndarray: Power output calculated using the given formula.
    """
    # Convert angular velocity from RPM to radians per second
    omega = (2 * np.pi * N) / 60
    
    # Calculate power output using the formula P = omega * T
    power = omega * T
    return power

# Define ranges for angular velocity (N) and torque (T)
N_range = np.linspace(1000, 3000, 100)  # Angular velocity range in RPM
T_range = np.linspace(100, 500, 100)  # Torque range in Nm

# Create meshgrid for N and T
N_mesh, T_mesh = np.meshgrid(N_range, T_range)

# Calculate power output for the meshgrid
power_mesh = calculate_power(N_mesh, T_mesh)

# Create a 3D plot
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

# Plot the surface
surf = ax.plot_surface(N_mesh, T_mesh, power_mesh, cmap='viridis')

# Set axis labels
ax.set_xlabel('Angular Velocity (RPM)')
ax.set_ylabel('Torque (Nm)')
ax.set_zlabel('Power Output (W)')
ax.set_title('Motor Power Output')

# Add color bar
fig.colorbar(surf, label='Power Output (W)')

# Show the plot
plt.show()




0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?