Имитационная модель PythonPython

Программы на Python
Ответить
Anonymous
 Имитационная модель Python

Сообщение Anonymous »

Я моделирую действие нового дезинфицирующего средства на вирусы, передающиеся по воздуху.
Пересмотрите Python_Simulation_Model_SBT.py (код ниже), кто-нибудь знает, как:
• Добавьте поле ввода, которое принимает десятичные значения объемного расхода, м3/с, для управления дополнительным потоком воздуха через дверь.
• Устраните любые ошибки в программе.
Примечание: Объемный расход воздуха: вентиляция и инфильтрация воздуха обычно выражаются
объемным расходом воздуха, например м3/с

Код: Выделить всё

o Q = volumetric flow rate (m3/s)
o A = cross-sectional area of the door opening (m2)
o V = average velocity of air through the door (m/s)

Q = VA
Спасибо,
Семен

Код: Выделить всё

# By Simeon Beckford-Tongs BSc MSc Copyright © 2023. All rights reserved. By Simeon Beckford-Tongs BSc MSc Copyright © 2023. All rights reserved.
import tkinter as tk
import random
import math
import time
from threading import Thread
import matplotlib.pyplot as plt

# Global variables
collision_count = 0
is_running = True
time_list = []
collision_count_list = []

class Ball:
def __init__(self, canvas, x, y, diameter, color, type):
self.canvas = canvas
self.image = canvas.create_oval(x, y, x + diameter, y + diameter, fill=color)
self.diameter = diameter
self.radius = diameter / 2
self.x_speed = random.randint(-6, 6)
self.y_speed = random.randint(-6, 6)
self.type = type
self.mass = self.radius ** 2

def move(self):
self.apply_buoyancy()
self.apply_air_resistance()
self.canvas.move(self.image, self.x_speed, self.y_speed)
self.check_boundary_collision()

def apply_buoyancy(self):
buoyant_force = -0.005 * self.mass
self.y_speed += buoyant_force / self.mass

def apply_air_resistance(self):
drag_factor = 0.00000014  # Value in standard form and reference below
#Ā0 = 1.4 × 10−8 N·s/m
#[https://www.pnas.org/doi/10.1073/pnas.0602043103#:~:text=The%20translational%20drag%20coefficient%20of,is%20due%20to%20the%20flagella.]

# Calculate the magnitude of the speed
speed_magnitude = math.sqrt(self.x_speed**2 + self.y_speed**2)

# Calculate the reduction in speed, more reduction for higher speeds
speed_reduction = drag_factor * speed_magnitude**2

# Apply the reduction to the x and y components of the speed
# Ensure we don't reverse the direction due to drag
self.x_speed = self.x_speed - (speed_reduction * self.x_speed / speed_magnitude) if self.x_speed != 0 else 0
self.y_speed = self.y_speed - (speed_reduction * self.y_speed / speed_magnitude) if self.y_speed != 0 else 0

def check_boundary_collision(self):
pos = self.canvas.coords(self.image)
if len(pos) != 4:
return
if pos[2] >= self.canvas.winfo_width() or pos[0] = self.canvas.winfo_height() or pos[1] 

Подробнее здесь: [url]https://stackoverflow.com/questions/79245853/python-simulation-model[/url]
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Python»