Mechanical Power System

From VintageCraft Wiki
Jump to: navigation, search

Technical Concept

Mechanical Power Relay

Variables: Direction

  • Axle, bidirectional transmission of mechanical power

Mechanical Power Node

Power node variables:

  • availableTorque: How much torque can this node produce
  • maxspeed: At what would it run under Zero Load
  • resistance(speed): Takes speed as a parameter, return hows murch torque it consumes
  • direction: clock-wise or counter-clock-wise

Power node properties:

  • Produces or consumes mechanical power
  • As soon as transmission device is connected to such block, a mechanical network will be created
  • A gear box transmit power from one mechanical network to another
  • Each connector of a power node creates a new network

Mechanical Network

Network properties: Speed, totalAvailableTorque, totalUnusedTorque, totalResistance

  • totalUnusedTorque = Math.max(0, totalAvailableTorque - totalResistance)
  • Entire network runs at one speed
  • Max Network speed = The max speed of any power producers in the network that is able to satisfy the requiredTorque. Example:

Example:

Mech. Power node A with MaxSpeed = 100, availableTorque= 50

Mech. Power node B with MaxSpeed = 50, availableTorque=150, resistance(speed) = math.max(0, 2 * (speed - maxspeed))


For no other power nodes:

  • Node B will drain power from Node A, as it runs at slower speeds. All 50 torque of node A will get consumed by node B. The network will speed up just fine until 50. Now the speed up will be slower and slower from the increasing resistance of node B until the point where all of Node A's torque is consumed by node B.

Final speed: Jumping between 74-75

Available torque: Jumping between 0-2

Energy transfer between Networks

  • Transfer of energy happens to the network with lower speed => has to be 1 tick later :(
  • Read resistance(speed) from lower speed network and set
    • 1. As power consumer for higher speed network with resistance(speed) from lower speed network
    • 2. As power producer for lower speed network with availableTorque = totalFreeTorque from higher speed network


Block placement

When a mechanical power relay block is placed

1. Check all 6 direct neigbhour devices, discard all that cannot connect to the current block 2. When

  - Remaining devices are in the same network => assign network to current block
  - Remaining devices are in the same network, but some have no network => propagate network to those without
  - Remaining devices are in different networks => throw new RuntimeException
  - No device is in a network => do nothing


When a mechanical power node block is placed

1. Check all 6 direct neigbhour devices, discard all that cannot connect to the current block

  - Remaining devices are in the same network => assign network to current block
  - Remaining devices are in different networks => throw new RuntimeException
  - No device is in a network => create new network. Propagate network instantiation through all connected blocks

Block removal

When any mechanical power block is removed

1. Get all connected neighbour devices 2. When

  - Quantity of connected neighbour devices is 2 or more => re-propagate connected networks and rebuild them starting from the first power node 
  - Quantity of connected neighbour devices less than 2 => do nothing