fix: restore original simple_refrig_api and platform path fixes
This commit is contained in:
12
scripts/container_check.py
Normal file
12
scripts/container_check.py
Normal file
@@ -0,0 +1,12 @@
|
||||
import traceback, sys
|
||||
try:
|
||||
from app.core.refrigerant_loader import RefrigerantLibrary
|
||||
r = RefrigerantLibrary('R290')
|
||||
print('Loaded Refifc OK')
|
||||
try:
|
||||
print('pbegin', r.p_begin())
|
||||
except Exception as e:
|
||||
print('p_begin failed:', e)
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
sys.exit(1)
|
||||
58
scripts/run_api_tests.py
Normal file
58
scripts/run_api_tests.py
Normal file
@@ -0,0 +1,58 @@
|
||||
import requests, json, base64, os
|
||||
base = 'http://127.0.0.1:8001'
|
||||
print('Health ->', requests.get(base + '/api/v1/health').json())
|
||||
# Diagram JSON
|
||||
body = {
|
||||
'refrigerant': 'R290',
|
||||
'pressure_range': {'min': 0.1, 'max': 10.0},
|
||||
'format': 'json',
|
||||
'include_isotherms': True,
|
||||
'width': 800,
|
||||
'height': 600,
|
||||
'dpi': 100
|
||||
}
|
||||
print('\nRequesting diagram JSON...')
|
||||
r = requests.post(base + '/api/v1/diagrams/ph', json=body, timeout=60)
|
||||
print('Status', r.status_code)
|
||||
try:
|
||||
j = r.json()
|
||||
print('Keys in response:', list(j.keys()))
|
||||
if 'data' in j:
|
||||
print('Saturation curve length:', len(j['data'].get('saturation_curve', [])))
|
||||
except Exception as e:
|
||||
print('Failed to parse JSON:', e, r.text[:200])
|
||||
|
||||
# Diagram PNG
|
||||
body['format'] = 'png'
|
||||
print('\nRequesting diagram PNG...')
|
||||
r2 = requests.post(base + '/api/v1/diagrams/ph', json=body, timeout=60)
|
||||
print('Status', r2.status_code)
|
||||
try:
|
||||
j2 = r2.json()
|
||||
print('Keys in response:', list(j2.keys()))
|
||||
if 'image' in j2:
|
||||
img_b64 = j2['image']
|
||||
os.makedirs('test_outputs', exist_ok=True)
|
||||
path = os.path.join('test_outputs','sample_diagram.png')
|
||||
with open(path, 'wb') as f:
|
||||
f.write(base64.b64decode(img_b64))
|
||||
print('Saved PNG to', path)
|
||||
except ValueError:
|
||||
print('Response is not JSON, printing text length', len(r2.text))
|
||||
|
||||
# Simple cycle (pressure mode)
|
||||
print('\nRequesting simple cycle...')
|
||||
cycle_body = {
|
||||
'refrigerant': 'R290',
|
||||
'evap_pressure': 0.2, # bar
|
||||
'cond_pressure': 6.0, # bar
|
||||
'superheat': 5.0,
|
||||
'subcool': 2.0,
|
||||
'mass_flow': 0.1
|
||||
}
|
||||
r3 = requests.post(base + '/api/v1/cycles/simple', json=cycle_body, timeout=60)
|
||||
print('Status', r3.status_code)
|
||||
try:
|
||||
print('Simple cycle keys:', list(r3.json().keys()))
|
||||
except Exception as e:
|
||||
print('Failed to parse cycle response:', e, r3.text[:200])
|
||||
78
scripts/run_api_tests_docker.py
Normal file
78
scripts/run_api_tests_docker.py
Normal file
@@ -0,0 +1,78 @@
|
||||
import requests, json, base64, os
|
||||
base = 'http://127.0.0.1:8002'
|
||||
print('Health ->', requests.get(base + '/api/v1/health').json())
|
||||
# Diagram JSON
|
||||
body = {
|
||||
'refrigerant': 'R290',
|
||||
'pressure_range': {'min': 0.1, 'max': 10.0},
|
||||
'format': 'json',
|
||||
'include_isotherms': True,
|
||||
'width': 800,
|
||||
'height': 600,
|
||||
'dpi': 100
|
||||
}
|
||||
print('\nRequesting diagram JSON...')
|
||||
r = requests.post(base + '/api/v1/diagrams/ph', json=body, timeout=120)
|
||||
print('Status', r.status_code)
|
||||
try:
|
||||
j = r.json()
|
||||
print('Keys in response:', list(j.keys()))
|
||||
if 'data' in j:
|
||||
print('Saturation curve length:', len(j['data'].get('saturation_curve', [])))
|
||||
except Exception as e:
|
||||
print('Failed to parse JSON:', e, r.text[:200])
|
||||
|
||||
# Diagram PNG
|
||||
body['format'] = 'png'
|
||||
print('\nRequesting diagram PNG...')
|
||||
r2 = requests.post(base + '/api/v1/diagrams/ph', json=body, timeout=120)
|
||||
print('Status', r2.status_code)
|
||||
try:
|
||||
j2 = r2.json()
|
||||
print('Keys in response:', list(j2.keys()))
|
||||
if 'image' in j2:
|
||||
img_b64 = j2['image']
|
||||
os.makedirs('test_outputs', exist_ok=True)
|
||||
path = os.path.join('test_outputs','docker_sample_diagram.png')
|
||||
with open(path, 'wb') as f:
|
||||
f.write(base64.b64decode(img_b64))
|
||||
print('Saved PNG to', path)
|
||||
except Exception as e:
|
||||
print('Failed to parse PNG response:', e, r2.text[:200])
|
||||
|
||||
# Simple cycle (pressure mode)
|
||||
print('\nRequesting simple cycle (pressure mode)...')
|
||||
cycle_body = {
|
||||
'refrigerant': 'R290',
|
||||
'evap_pressure': 0.2, # bar
|
||||
'cond_pressure': 6.0, # bar
|
||||
'superheat': 5.0,
|
||||
'subcool': 2.0,
|
||||
'mass_flow': 0.1
|
||||
}
|
||||
r3 = requests.post(base + '/api/v1/cycles/simple', json=cycle_body, timeout=120)
|
||||
print('Status', r3.status_code)
|
||||
try:
|
||||
print('Simple cycle keys:', list(r3.json().keys()))
|
||||
except Exception as e:
|
||||
print('Failed to parse cycle response:', e, r3.text[:200])
|
||||
|
||||
# Simple cycle (temperature mode)
|
||||
print('\nRequesting simple cycle (temperature mode)...')
|
||||
cycle_body2 = {
|
||||
'refrigerant': 'R290',
|
||||
'evap_temperature': -10.0,
|
||||
'cond_temperature': 40.0,
|
||||
'superheat': 5.0,
|
||||
'subcool': 2.0,
|
||||
'mass_flow': 0.1
|
||||
}
|
||||
r4 = requests.post(base + '/api/v1/cycles/simple', json=cycle_body2, timeout=120)
|
||||
print('Status', r4.status_code)
|
||||
try:
|
||||
j4 = r4.json()
|
||||
print('Keys:', list(j4.keys()))
|
||||
if 'performance' in j4:
|
||||
print('COP:', j4['performance'].get('cop'))
|
||||
except Exception as e:
|
||||
print('Failed to parse cycle temp response:', e, r4.text[:200])
|
||||
25
scripts/test_cycle_temp.py
Normal file
25
scripts/test_cycle_temp.py
Normal file
@@ -0,0 +1,25 @@
|
||||
import requests, json
|
||||
base = 'http://127.0.0.1:8001'
|
||||
print('Health ->', requests.get(base + '/api/v1/health').json())
|
||||
|
||||
body = {
|
||||
'refrigerant': 'R290',
|
||||
'evap_temperature': -10.0, # °C
|
||||
'cond_temperature': 40.0, # °C
|
||||
'superheat': 5.0,
|
||||
'subcool': 2.0,
|
||||
'mass_flow': 0.1
|
||||
}
|
||||
print('\nRequesting simple cycle (temperature mode)...')
|
||||
r = requests.post(base + '/api/v1/cycles/simple', json=body, timeout=60)
|
||||
print('Status', r.status_code)
|
||||
try:
|
||||
j = r.json()
|
||||
print('Keys:', list(j.keys()))
|
||||
if 'performance' in j:
|
||||
print('COP:', j['performance'].get('cop'))
|
||||
print('Compressor efficiency:', j['performance'].get('compressor_efficiency'))
|
||||
if 'diagram_data' in j:
|
||||
print('Diagram cycle points count:', len(j['diagram_data'].get('cycle_points', [])))
|
||||
except Exception as e:
|
||||
print('Failed to parse JSON:', e, r.text[:200])
|
||||
28
scripts/test_economizer.py
Normal file
28
scripts/test_economizer.py
Normal file
@@ -0,0 +1,28 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
# Ensure project root is on sys.path so 'app' package is importable when running scripts
|
||||
ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
|
||||
if ROOT not in sys.path:
|
||||
sys.path.insert(0, ROOT)
|
||||
|
||||
from app.core.refrigerant_loader import RefrigerantLibrary
|
||||
from app.services.cycle_calculator import CycleCalculator
|
||||
|
||||
# Create refrigerant and calculator
|
||||
refrig = RefrigerantLibrary('R290')
|
||||
calc = CycleCalculator(refrig)
|
||||
|
||||
# Typical pressures in Pa (convert from bar)
|
||||
evap = 0.2 * 1e5
|
||||
cond = 6.0 * 1e5
|
||||
inter = 2.0 * 1e5
|
||||
|
||||
res = calc.calculate_cycle_with_economizer(evap, cond, inter, superheat=5.0, subcool=3.0, mass_flow=0.1)
|
||||
|
||||
print('Economizer result keys:', res.keys())
|
||||
print('Flash fraction:', res['performance'].get('flash_fraction'))
|
||||
print('COP:', res['performance'].get('cop'))
|
||||
print('Points:')
|
||||
for p in res['points']:
|
||||
print(' -', p)
|
||||
Reference in New Issue
Block a user