Untitled
beq
c_cpp
2 years ago
1.8 kB
7
Indexable
// Получение точек для зависимости силы тока от времени
std::vector<std::pair<double, double>> CalculateCurrentOverTime(double R, double f, double L, double A, double C, int Period) {
std::vector<std::pair<double, double>> currentPoints;
double omega = 2 * 3.14159 * f;
double maxTime = Period * (1 / f); // первое число - кол-во периодов
double timeStep = 0.001;
double time = 0;
while (time <= maxTime) {
// Рассчитываем силу тока для каждого момента времени
double current = A * sin(omega * time) / sqrt(pow(R, 2) + pow(omega * L - 1 / (omega * C), 2));
currentPoints.push_back(std::make_pair(time, current));
time += timeStep;
}
return currentPoints;
}
// Получение точек для зависимости напряжения от времени
std::vector<std::pair<double, double>> IncreasingSineWave(double R, double f, double L, double A, double C, double maxAmplitude, int Period) {
std::vector<std::pair<double, double>> voltagePoints;
double omega = 2 * 3.14159 * f;
double maxTime = Period * (1 / f); // первое число - кол-во периодов
double timeStep = 0.001;
double time = 0;
for (double t = 0; t <= maxTime; t += timeStep) {
double amplitude = A * (1 - exp(-t)); // Рассчитываем изменение амплитуды по мере времени
if (amplitude > maxAmplitude) {
amplitude = maxAmplitude; // Ограничиваем амплитуду максимальным значением
}
double voltage = amplitude * std::cos(omega * t) * exp(-R * t / (2 * L * C));
voltagePoints.push_back(std::make_pair(t, voltage));
}
return voltagePoints;
}Editor is loading...
Leave a Comment