# Výpočet teploty vody

• ### Dotaz

• Zdravím potřeboval bych pomoci se vzorci na výpočet vody. Řešil někdo podobný problém?
úterý 8. května 2018 16:43

### Odpovědi

• Kdysi dávno jsem si to zkoušel pro nádrž na zahradě mnooo, ale nejsem si jist, zda to funguje

private void Form1_Load(object sender, EventArgs e)
{
timer1.Interval = _timerInterval;
timer1.Start();
}

private int _timerInterval = 100;
private double _simStart = 0;
private bool _valveIsOpened = true;
private bool _isHeating = true;
double _valveShowerOutput = 0;
double _valveSinkOutput = 0;
double _waterUsedL = 0;
double _valveShowerTemperature = 10;
double _valveSinkTemperature = 10;
private double _currentWatrerTemp = 20;
private double _inputWaterTemp = 10;

//bojler
static double BoilerHeightCm = 200;
double _curremtWaterVol = Math.PI * Math.Pow((BoilerRadiusCm / 10), 2) * (BoilerHeightCm / 10);
double DrainPerTick => (_valveShowerOutput / 60 / 1000) * _timerInterval + (_valveSinkOutput / 60 / 1000) * _timerInterval;
int BoilerPathStartPointX = 100;
int BoilerPathStartPointY = 100;
int BoilerPathHeight = 400;
int BoilerPathWidth = 300;

//fyzika
private double _waterHeatCap = 4180;
double RequiredWaterTemperatureMinC = 50;
double RequiredWaterTemperatureMaxC = 70;
double WaterTemperatureUltimateMaxC = 80;
double WaterBlueColorTemperatureStart = 50;
double WaterRedColorTemperatureStart = 80;
//ohřevné těleso
double _performanceWatt = 4000;

//max průtok trubkama
double ValveSinkMaxOutput = 150;
double ValveShowerMaxOutput = 300;
private void timer1_Tick(object sender, EventArgs e)
{
_simStart += _timerInterval * 1;

if (_valveIsOpened)
{
_waterUsedL += DrainPerTick;
var maxWaterL = _curremtWaterVol;
_curremtWaterVol -= DrainPerTick;
var neededWaterInput = maxWaterL - _curremtWaterVol;

double resltTemperatureAfterWaterInput =
(_curremtWaterVol * _waterHeatCap * _currentWatrerTemp -
_inputWaterTemp * neededWaterInput * _waterHeatCap) /
(_waterHeatCap * (-neededWaterInput + _curremtWaterVol));
_currentWatrerTemp = _currentWatrerTemp - (resltTemperatureAfterWaterInput - _currentWatrerTemp);
}

if (_isHeating)
{
var coilHeatCreated = _timerInterval * _performanceWatt;
var tempDif = coilHeatCreated / (_curremtWaterVol * _waterHeatCap) + _currentWatrerTemp;
_currentWatrerTemp = tempDif;
}
if (_currentWatrerTemp > 20)
{
var lostHeat = _timerInterval * 100;
var lostTemp = (lostHeat / _curremtWaterVol * _waterHeatCap);
var finalLostTemp = lostTemp - _curremtWaterVol;
_currentWatrerTemp -= finalLostTemp;
if (_currentWatrerTemp < 20)
{
_currentWatrerTemp = 20;
}
}

//automatické ovládání
if (_currentWatrerTemp < RequiredWaterTemperatureMinC)
{
_isHeating = true;
}
else if (_currentWatrerTemp > RequiredWaterTemperatureMaxC)
{
_isHeating = false;
}
if (_valveIsOpened)
{
_curremtWaterVol += DrainPerTick;
}
UpdateInfo();
}
private void UpdateInfo()
{
TimeSpan simTime = TimeSpan.FromMilliseconds(_simStart);
labelSimTime.Text = \$"{simTime.Hours.ToString("00")};" +
\$"{simTime.Minutes.ToString("00")}:" +
\$"{simTime.Seconds.ToString("00")}:" +
\$"{simTime.Milliseconds.ToString("00")}";
labelDrain.Text = DrainPerTick.ToString();
labelWaterUsed.Text = Math.Round(_waterUsedL, 3).ToString();
labelTemp.Text = @"Teplota vody je: " + Math.Round(_currentWatrerTemp, 3) + @" C";
Invalidate();
}

private void trackBarShower_Scroll(object sender, EventArgs e)
{
_valveShowerOutput = ValveShowerMaxOutput * ((double)trackBarShower.Value / 100);
labelTrSh.Text = _valveShowerOutput.ToString();
}

private void trackBarSink_Scroll(object sender, EventArgs e)
{
_valveSinkOutput = ValveSinkMaxOutput * ((double)trackBarSink.Value / 100);
labelTrSn.Text = _valveSinkOutput.ToString();
}

private void Form1_Paint(object sender, PaintEventArgs e)
{
//horni trubky
e.Graphics.DrawLine(Pens.Black, BoilerPathStartPointX + 9, 0, BoilerPathStartPointX + 9, BoilerPathStartPointY);
e.Graphics.DrawLine(Pens.Black, BoilerPathStartPointX + 18, 0, BoilerPathStartPointX + 18, BoilerPathStartPointY);
if (_valveShowerOutput > 0 || _valveSinkOutput > 0)
{
e.Graphics.FillRectangle(Brushes.Blue, BoilerPathStartPointX + 10, 0, 8, BoilerPathStartPointY);
}
int waterHeight = BoilerPathHeight * (int)_hladinaVody / 100;
Rectangle waterRec = new Rectangle(BoilerPathStartPointX, BoilerPathStartPointY + BoilerPathHeight - waterHeight, BoilerPathWidth, waterHeight);
var temperature = WaterRedColorTemperatureStart - WaterBlueColorTemperatureStart;
var redPercentage = (_currentWatrerTemp - WaterBlueColorTemperatureStart) / temperature * 255;
if (redPercentage > 255)
{
redPercentage = 255;
}
else if (redPercentage < 0)
{
redPercentage = 0;
}
var bluePercentage = 255 - redPercentage;
var waterBlueCol = Color.FromArgb((int)bluePercentage, 255, 0, 0);
var waterRedCol = Color.FromArgb((int)redPercentage, 255, 0, 0);
e.Graphics.FillRectangle(new SolidBrush(waterBlueCol), waterRec);
e.Graphics.FillRectangle(new SolidBrush(waterRedCol), waterRec);
//boiler
e.Graphics.DrawLine(Pens.Black, BoilerPathStartPointX, BoilerPathStartPointY, BoilerPathStartPointX, BoilerPathStartPointY + BoilerPathHeight);
e.Graphics.DrawLine(Pens.Black, BoilerPathStartPointX, BoilerPathStartPointY + BoilerPathHeight, BoilerPathStartPointX + BoilerPathWidth, BoilerPathStartPointY + BoilerPathHeight);
e.Graphics.DrawLine(Pens.Black, BoilerPathStartPointX + BoilerPathWidth, BoilerPathStartPointY + BoilerPathHeight, BoilerPathStartPointX + BoilerPathWidth, BoilerPathStartPointY);
var valvesX = BoilerPathStartPointX + BoilerPathWidth;
var valvesY = BoilerPathStartPointY + BoilerPathHeight;

float valvesWidth = 9;
float valvesSpacing = 0;

e.Graphics.DrawLine(Pens.Black, valvesX - valvesWidth * 4 - valvesSpacing, valvesY, valvesX - valvesWidth * 4 - valvesSpacing, ClientRectangle.Height);
e.Graphics.DrawLine(Pens.Black, valvesX - valvesWidth * 3 - valvesSpacing, valvesY, valvesX - valvesWidth * 3 - valvesSpacing, ClientRectangle.Height);
if (_valveShowerOutput > 0)
{
e.Graphics.DrawLine(new Pen(waterBlueCol, 8), valvesX - valvesWidth * 4 - valvesSpacing + valvesWidth / 2, valvesY, valvesX - valvesWidth * 4 - valvesSpacing + valvesWidth / 2, ClientRectangle.Height);
e.Graphics.DrawLine(new Pen(waterRedCol, 8), valvesX - valvesWidth * 4 - valvesSpacing + valvesWidth / 2, valvesY, valvesX - valvesWidth * 4 - valvesSpacing + valvesWidth / 2, ClientRectangle.Height);
}

e.Graphics.DrawLine(Pens.Black, valvesX - valvesWidth * 2 - valvesSpacing, valvesY, valvesX - valvesWidth * 2 - valvesSpacing, ClientRectangle.Height);
e.Graphics.DrawLine(Pens.Black, valvesX - valvesWidth * 1 - valvesSpacing, valvesY, valvesX - valvesWidth * 1 - valvesSpacing, ClientRectangle.Height);
if (_valveSinkOutput>0)
{
e.Graphics.DrawLine(new Pen(waterBlueCol, 8), valvesX - valvesWidth * 2 - valvesSpacing + valvesWidth / 2, valvesY, valvesX - valvesWidth * 2 - valvesSpacing + valvesWidth / 2, ClientRectangle.Height);
e.Graphics.DrawLine(new Pen(waterRedCol, 8), valvesX - valvesWidth * 2 - valvesSpacing + valvesWidth / 2, valvesY, valvesX - valvesWidth * 2 - valvesSpacing + valvesWidth / 2, ClientRectangle.Height);
}
}

úterý 8. května 2018 16:44