I have all the basic physics working for every major section of the entire generator as correctly as I think I can (barring actual code implementation improvements) but just couldn't get the feedback of the generated current, which causes resistance against the flux, to cause the correct resistance.

Here is the closest working code I have tried:

```
set Hz to (coilVeffect * (magNum/2)) * (AvRPM/60)
set AvVoltage to (totalFlux * wireToMagAv) * (loopsPerCoil * Coilcount)
set AvAmps to AvVoltage/totalOhm
set PeakRPM to ((AccumulativeRotationalForce * (RotationDistance/RotationalForce))/60) * RPMGearRatio
set PeakAmps to ((((CoilVEffect * (magNum/2)) * (peakRPM/60)) * ((totalFlux *2) * wireToMagAv) * (loopsPerCoil * coilCount))) *(AvVoltage/totalOhm)) / ((coilVEffect * (magNum/2)) * (AvRPM/60)
set PeakWattage to (WireCount * (PeakAmps * AvVoltage)) * coilLayers
set PeakAmps to PeakWattage / ((OutputLoadAmperage * 1.73) *0.8)
set PeakWattagePostLoadEffect to ((WireCount * (PeakAmps * AvVoltage)) *coilLayers
set PeakWattage to (WireCount * (PeakAmps * AvVoltage)) * coilLayers
set OutputLoadEffect to PeakWattagePostLoadEffect/PeakWattage
set AvAmps to OutputLoadEffect * (AvVoltage/totalOhm)
set Power to (wireCount * (AvAmps * AvVoltage)) *coilLayers
if broken=0 then
set cycleOutputinWatts to (((Hz * Power) * timeElapsed) * OutputLoadEffect) /2
```

I have tried to average out what effect the feedback would have had throughout the run after the fact.

This is the project. It is basically a wind turbine on its side with a threaded weight instead of wind. If anyone can take a look and explain how best to go about this more accurately, that would be awesome. Better would be to remix the project and also enable the cloud highscore for largest output per run to work correctly, because I didn't manage that either. I became very interested in what I could do with code very quickly and began experimenting with what computers did, but this first project of mine still rankles and I would love for it to do what I intended it to do. Mainly, save all the variables for the highscores on the cloud so we can compete to make the best fuel free generator.

**Thankyou for your time and effort. I can see how this is easily misinterpreted and will try to explain.**

you appear to be doing a lot of calculations which are unnecessary

```
set Hz to (coilVeffect * (magNum/2)) * (AvRPM/60)
```

If Hz is the commutation cycle frequency (ie. 'electrical' rpm) then why do you multiply it by the constant coilVeffect?

**The Hz is how often each magnet passes through a coil. This is based on the rotation of the threaded weight (wind equivalent) and is slowed down by the resistance created in the coils to the flux represented by CoilVEffect.**

**It is this coilVEffect that i am having difficulties with calculating accurately and is the entire reason for this code.**

```
set PeakAmps to ((((CoilVEffect * (magNum/2)) * (peakRPM/60))... .
set PeakAmps to PeakWattage / ((OutputLoadAmperage * 1.73) *0.8)
```

Amps = Watts / Volts, not Watts / Amps. It's not clear what the constants 1.73 and 0.8 are (delta wind? efficiency?) or why you need to calculate peak Amps at all, but reusing a variable for different purposes is bad coding style.

**Peaks are used to review breakages (overheating/stress) in a run. The constant is an efficiency modifier, I did mistakenly think i missed the AvVoltage for a bit but it should be the constant (i am fairly sure) and i need to recalculate the same peak after changing a dependency, The PeakWattage. I soon after recalculate Peakwattage too for the same reason.**

```
set Power to (wireCount * (AvAmps * AvVoltage)) *coilLayers
```

Power = Amps * Volts. So what are wireCount and coilLayers doing in this calculation?

**There is potentially more than a single layer of dynamo spun by the weight (coilLayers and wirecount) and this combines all layers. The calculations you have expected here are already done elsewhere.**

```
set cycleOutputinWatts to (((Hz * Power) * timeElapsed) * OutputLoadEffect) /2
```

Finally the purpose of Hz is revealed! Or not. Power = energy / time.

I have no idea what OutputLoadEffect is doing

**This is the number of passes through the coils the energy made in each how long it keeps happening for. OutputLoadEffect is however many serial/parallel batteries being charged effect the draw through the system**

**I can still use the breakages report from before this block runs as I should only be lowering the peaks. If there have been no breaks with the higher peaks then this is still safe. this does mean that finding out what the Actual peak output calculates to for any combination of variations is currently impossible because the breaks register above the real capability. I just call it a safety buffer but i would much prefer to get rid of this discrepancy.**

**I half the cycles output to account for the worst case of various inefficiencies. This is what I hope to be an overcautious guess.**

**I am making this as accurate as i can to the smallest detail and keeping the ability to to change almost every aspect of the design in many ways.**

If all aspects of the design can be changed (eg. different coil shapes, airgaps, magnetic materials etc.) then it becomes a lot more difficult to simulate accurately.

**Yes. It does.**

## Best Answer

It's hard to tell from the snippet of code provided, but you appear to be doing a lot of calculations which are unnecessary or even just plain wrong. For example,

If

`Hz`

is the commutation cycle frequency (ie. 'electrical' rpm) then why do you multiply it by the constant`coilVeffect`

?Amps = Watts /

Volts, not Watts / Amps. It's not clear what the constants 1.73 and 0.8 are (delta wind? efficiency?) or why you need to calculate peak Amps at all, but reusing a variable for different purposes is bad coding style.Power = Amps * Volts. So what are

`wireCount`

and`coilLayers`

doing in this calculation?Finally the purpose of

`Hz`

is revealed! Or not. Power = energy / time. Assuming all the variables are appropriately named - in this line you multiply power by time to get energy, then multiply by frequency (1/time) to get the 'power' during one cycle. So you started with power, and ended up with power again. I have no idea what`OutputLoadEffect`

is doing, but the whole calculation seems to be a waste of time.Perhaps my interpretation is wrong, and everything would make sense if only I knew what each variable represents. But your code is still obscure and difficult to understand.

Are you designing a game? I suggest you forget about trying to simulate a generator from first principles, and just create an algorithm which produces a realistic output from variables that the 'players' can change. Start with a simple model, and add just enough complexity to get reasonable accuracy. Develop 'constants' (Kt, Rm etc.) from the design parameters, then use these to calculate the generator's performance.

With a simulation it is easy to get unrealistic results if you are not careful. Real machines have conflicting design parameters that limit their performance. For example you can increase the number of turns to produce higher voltage - but that either increases winding resistance (because the wire is longer and thinner) or increases magnetic reluctance (because you have to reduce the amount of iron to make room for more copper) or makes the machine larger (which increases rotational losses).

For a generator of a particular design and size, changing one parameter will affect others with the result that torque input and power output remains the same no matter what voltage and current it can produce. This makes your calculations easier. If all aspects of the design can be changed (eg. different coil shapes, airgaps, magnetic materials etc.) then it becomes a

lotmore difficult to simulate accurately.