Add .gitignore and commit pending changes
- Add comprehensive .gitignore for Python, Flask, IDE, and project-specific files - Include test_optimizer.py - Update Claude settings and windings preset configuration 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -4,7 +4,13 @@
|
||||
"Bash(if [ -d .cursor/rules ])",
|
||||
"Bash(then ls .cursor/rules)",
|
||||
"Bash(fi)",
|
||||
"Bash(python:*)"
|
||||
"Bash(python:*)",
|
||||
"Bash(d:/tx/transformer/.venv/Scripts/python.exe:*)",
|
||||
"Read(//d/**)",
|
||||
"Bash(.venv/Scripts/python.exe draw_toroid.py:*)",
|
||||
"Bash(.venv/Scripts/python.exe:*)",
|
||||
"Bash(git add .gitignore test_optimizer.py .claude/settings.local.json presets/windings.json)",
|
||||
"Bash(git commit -m \"$(cat <<''EOF''\nAdd .gitignore and commit pending changes\n\n- Add comprehensive .gitignore for Python, Flask, IDE, and project-specific files\n- Include test_optimizer.py\n- Update Claude settings and windings preset configuration\n\n🤖 Generated with [Claude Code](https://claude.com/claude-code)\n\nCo-Authored-By: Claude <noreply@anthropic.com>\nEOF\n)\")"
|
||||
],
|
||||
"deny": [],
|
||||
"ask": []
|
||||
|
||||
50
.gitignore
vendored
Normal file
50
.gitignore
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
# Python
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
*.so
|
||||
.Python
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
wheels/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
|
||||
# Virtual Environment
|
||||
.venv/
|
||||
venv/
|
||||
ENV/
|
||||
env/
|
||||
|
||||
# Flask
|
||||
instance/
|
||||
.webassets-cache
|
||||
|
||||
# IDE
|
||||
.vscode/
|
||||
.idea/
|
||||
*.swp
|
||||
*.swo
|
||||
*~
|
||||
|
||||
# OS
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
# Project specific
|
||||
*.png
|
||||
sweep_results.csv
|
||||
old/
|
||||
|
||||
# Local settings
|
||||
.claude/settings.local.json
|
||||
@@ -5,8 +5,8 @@
|
||||
"name": "primary",
|
||||
"taps": [
|
||||
0,
|
||||
25,
|
||||
50
|
||||
50,
|
||||
25
|
||||
],
|
||||
"awg": [
|
||||
20,
|
||||
@@ -23,10 +23,10 @@
|
||||
50
|
||||
],
|
||||
"awg": [
|
||||
20,
|
||||
22,
|
||||
28,
|
||||
28
|
||||
22,
|
||||
22,
|
||||
22
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
90
test_optimizer.py
Normal file
90
test_optimizer.py
Normal file
@@ -0,0 +1,90 @@
|
||||
from model import TransformerModel
|
||||
from optimizer import TransformerOptimizer
|
||||
|
||||
# Create the same transformer as in app.py
|
||||
primary_taps = [0, 75, 75]
|
||||
secondary_taps = [0, 100, 150, 150, 150]
|
||||
|
||||
primary_Rp_per_turn = [0.01, 0.01]
|
||||
secondary_Rs_per_turn = [0.004, 0.024, 0.024, 0.024]
|
||||
|
||||
tf = TransformerModel(
|
||||
Ae_mm2=354.0,
|
||||
Ve_mm3=43900.0,
|
||||
use_core_loss_model=True,
|
||||
Np_total=150,
|
||||
Ns_total=250,
|
||||
primary_taps=primary_taps,
|
||||
secondary_taps=secondary_taps,
|
||||
primary_Rp_per_turn=primary_Rp_per_turn,
|
||||
secondary_Rs_per_turn=secondary_Rs_per_turn,
|
||||
)
|
||||
|
||||
# Test case: 300Hz, 10ohm, 25W target
|
||||
print("Testing with B_max_T=0.3T:")
|
||||
opt = TransformerOptimizer(tf)
|
||||
result = opt.optimize(
|
||||
load_ohms=10.0,
|
||||
target_power_W=25.0,
|
||||
freq_hz=300.0,
|
||||
Vp_min=5.0,
|
||||
Vp_max=50.0,
|
||||
Vp_step=0.5,
|
||||
B_max_T=0.3,
|
||||
Vs_max=200.0,
|
||||
core_loss_W=0.0,
|
||||
power_tolerance_percent=2.0,
|
||||
)
|
||||
|
||||
if result:
|
||||
print(f"Optimizer result:")
|
||||
print(f" Primary tap: {result.primary_tap}, Secondary tap: {result.secondary_tap}")
|
||||
print(f" Vp_rms: {result.Vp_rms:.2f}V")
|
||||
print(f" Efficiency: {result.efficiency*100:.2f}%")
|
||||
print(f" Power out: {result.P_out_W:.2f}W")
|
||||
print(f" B_peak: {result.B_peak_T:.4f}T")
|
||||
print()
|
||||
|
||||
print("\nTesting with B_max_T=0.35T:")
|
||||
result2 = opt.optimize(
|
||||
load_ohms=10.0,
|
||||
target_power_W=25.0,
|
||||
freq_hz=300.0,
|
||||
Vp_min=5.0,
|
||||
Vp_max=50.0,
|
||||
Vp_step=0.5,
|
||||
B_max_T=0.35,
|
||||
Vs_max=200.0,
|
||||
core_loss_W=0.0,
|
||||
power_tolerance_percent=2.0,
|
||||
)
|
||||
|
||||
if result2:
|
||||
print(f"Optimizer result:")
|
||||
print(f" Primary tap: {result2.primary_tap}, Secondary tap: {result2.secondary_tap}")
|
||||
print(f" Vp_rms: {result2.Vp_rms:.2f}V")
|
||||
print(f" Efficiency: {result2.efficiency*100:.2f}%")
|
||||
print(f" Power out: {result2.P_out_W:.2f}W")
|
||||
print(f" B_peak: {result2.B_peak_T:.4f}T")
|
||||
print()
|
||||
|
||||
# Now try manual settings to see what 85% efficiency looks like
|
||||
print("Manual test - trying different tap combinations:")
|
||||
for p_tap in [1, 2]:
|
||||
for s_tap in [1, 2, 3, 4]:
|
||||
for Vp in range(5, 51, 1): # 5V to 50V in 1V steps
|
||||
try:
|
||||
sim = tf.simulate(
|
||||
primary_tap=p_tap,
|
||||
secondary_tap=s_tap,
|
||||
Vp_rms=Vp,
|
||||
freq_hz=300.0,
|
||||
load_ohms=10.0,
|
||||
)
|
||||
eff_pct = sim['efficiency'] * 100
|
||||
if sim['P_out_W'] >= 20 and sim['P_out_W'] <= 30: # Close to target
|
||||
print(f" p={p_tap}, s={s_tap}, Vp={Vp}V: Pout={sim['P_out_W']:.1f}W, eff={eff_pct:.1f}%, B={sim['B_peak_T']:.4f}T, Pcore={sim['P_core_W']:.2f}W, Pcu={sim['P_cu_W']:.2f}W")
|
||||
except Exception as e:
|
||||
pass
|
||||
else:
|
||||
print("No solution found!")
|
||||
Reference in New Issue
Block a user