RedDeadlyCreeper/ArmoredCombatExtended

ERA REWORK

Closed this issue · 1 comments

Guys we decided to edit ERA code a little (just rewrite it meh) and this is our current concept of it in form of E2.
Feel free to mess with the values and formulas. More data, reports and suggestions we get from you - better will it be as a result.

ace_era_concept.txt

On impact any kind of penetrator considered to be a rod of some material.
Rougly speaking decrease of penetration depends on the amount of material that the rod had to go through and the properties of both materials.
For HEAT and HEATFS special parameter IsSolid was added because obv penetrating jet acts like a stream of liquid instead of solid body so ERA plate can't change direction of the entire jet.

Current AP, APDS, APFSDS materials density and hardness are steel, wulfrum and tungsten respectively.
HEAT and HEATFS materials density are copper and tantalum, their hardness is imaginary as i have no idea what could it be in superplastic state.

# made by Delectros STEAM_0:0:144869639 #

@name ACE era concept

@persist APFSDS_Length APFSDS_Diameter
@persist APFSDS_RodLng APFSDS_RodDim
@persist APFSDS_RodDensity APFSDS_RodHardness
@persist APFSDS_Velocity APFSDS_RodPen
@persist APFSDS_Direction:vector APFSDS_IsSolid

@persist ERA_Thickness ERA_Density ERA_Hardness
@persist ERA_Velocity ERA_Direction:vector

@persist Impact_Angle

@persist Rod_Length AutoRun Presets:table

if (first()) {

# # Changable values for simulation     # #
# # Test shell 120mm APFSDS             # #
# # Rod diameter multiplier 0.35        # #
# # Velocity 1500m/s                    # #
# # Materials density rolative to steel # # Steel density 7.85g/cm3; Tungsten density 19.3g/cm3
APFSDS_Length      = 0.96  # # In meters
APFSDS_RodLng      = 0.75  # # Multiplier
APFSDS_Diameter    = 0.12  # # In meters
APFSDS_RodDim      = 0.35  # # Multiplier
APFSDS_RodDensity  = 19300 # # Multiplier of material density
APFSDS_RodHardness = 3000  # # Brinell hardness of tungsten is between 2000 and 4000
APFSDS_Velocity    = 1500  # # In Meters/second
APFSDS_Direction   = vec(1, 0, 0) # # Rod impact vector local to World
APFSDS_IsSolid     = 1     # # Only meant for HEAT because metal jet is not solid and ERA plate can't twist entire jet
# # APFSDS_RodPen     = 0.55  # # In meters penetration of a shell. Set to maximum value for the test purposes

ERA_Thickness = 0.014 # # In meters
ERA_Density   = 7850  # # Multiplier of material density
ERA_Hardness  = 400   # # Brinell hardness of RHA is between 320 and 400
ERA_Velocity  = 700   # # In meters/second
ERA_Direction = vec(-sin(45), 0, cos(45)) # # Era surface hitNormal local to World

Impact_Angle = asin(abs(APFSDS_Direction:dot(ERA_Direction))) # # Degrees between armor surface and rod direction

printColor(vec(223), "List of available commands:\n",
    vec(255, 223, 0), "  !sim", vec(223), " - runs the calculation of ERA influencing shell trajectory.\n",
    vec(255, 223, 0), "  !rod parameter value", vec(223), " - sets a value for one of shell parameters:\n",
    vec(191),         "   length, rodlng, diameter, roddim, roddensity, rodhardness, velocity, direction, issolid.\n",
    vec(255, 223, 0), "  !era parameter value", vec(223), " - sets a value for one of ERA parameters:\n",
    vec(191),         "   thickness, density, hardness, velocity, direction.\n",
    vec(255, 223, 0), "  !preset type", vec(223), " - sets all parameters to selected type:\n",
    vec(191),         "   AP, APDS, APFSDS, HEAT, HEATFS.\n",
    vec(255, 223, 0), "  !autorun", vec(223), " - runs the calculation after every parameter change.")

function void simulateERA () {
    # # Rod length and diameter don't require any explanation i guess
    # # Rod projection is the length of slice it will leave on the ERA plave 
    Rod_Length   = APFSDS_Length * APFSDS_RodLng / 1.3090909090909
    Rod_Diameter = APFSDS_Diameter * APFSDS_RodDim
    Rod_AreaYZ   = Rod_Diameter * _PI
    Rod_Volume   = Rod_AreaYZ * Rod_Length
    
    # # First we need to figure out how long is rod projection onto plate surface
    # # to measure the amount of material that got in contact with a rod.
    # # Lets consider plate to be static and transfer it's velocity onto a rod.
    Rod_LocalAngle = atan(ERA_Velocity / (APFSDS_Velocity * cos(Impact_Angle)))
    
    # # Lets measure volume of penetrated plate material # #
    ERA_AreaYZ    = Rod_AreaYZ / sin(Rod_LocalAngle)
    ERA_AreaXY    = Rod_Length * Rod_Diameter * cos(Rod_LocalAngle)
    ERA_AreaTotal = ERA_AreaYZ + ERA_AreaXY
    ERA_Volune    = ERA_AreaTotal * ERA_Thickness
    
    # # Now if we consider rod material volume to be it's penetration capability
    # # we should be able to reduce it's penetration by subtracting penetrated ERA material volume.
    Rod_Mass = Rod_Volume * APFSDS_RodDensity
    ERA_Mass = ERA_Volune * ERA_Density
    
    HardessCoef     = ERA_Hardness / APFSDS_RodHardness
    Rod_MassFinal   = Rod_Mass - ERA_Mass * HardessCoef
    #Rod_MassFinal   = Rod_Mass - ERA_Mass
    Rod_Penetration = Rod_Length / Rod_Mass * Rod_MassFinal # # Decreased penetration of a rod. Simple solution.
    
    # # Lets bring in simple solution for Rod angle after colliding with ERA.
    # # Tho actuall inertia don't include material hardness i'm including it 
    # # to simulate how likely materials are to deform upon collision rather than push eachother.
    Rod_Inertia = Rod_Mass * APFSDS_Velocity * APFSDS_RodHardness
    ERA_Inertia = ERA_Mass * ERA_Velocity    * ERA_Hardness
    
    # # To simplify things i'll just use entities inertia and direction vectors.
    # # And by entities i mean penetrator rod and penetrated volume of ERA
    Rod_Direction = APFSDS_IsSolid ? (APFSDS_Direction * Rod_Inertia + ERA_Direction * ERA_Inertia):normalized() : APFSDS_Direction
    
    
    Penetration_loss = round(100 - 100 / Rod_Length * Rod_Penetration, 3)
    printColor(vec(223), "Starting penetration: ", vec(255, 223, 0), round(Rod_Length, 3) + "m", vec(223), "    Final penetration: ", vec(255, 223, 0), round(Rod_Penetration, 3) + "m")
    printColor(vec(223), "Impact angle: ", vec(255, 223, 0), Impact_Angle + "deg", vec(223), "    Penetration loss: ", vec(255, 223, 0), Penetration_loss + "%")
    printColor(vec(223), "Penetration: ", vec(255, 223, 0), (Penetration_loss < 100) ? "true" : "false")
    printColor(vec(223), "Impact direction: ", vec(255, 223, 0), "" + round(APFSDS_Direction, 3), vec(223), "    Final direction: ", vec(255, 223, 0), "" + round(Rod_Direction, 3))
}

Presets = table(
    # # Reference # #
    # # APFSDS_Length      = 0.96  # # In meters
    # # APFSDS_RodLng      = 0.75  # # Multiplier
    # # APFSDS_Diameter    = 0.12  # # In meters
    # # APFSDS_RodDim      = 0.35  # # Multiplier
    # # APFSDS_RodDensity  = 19300 # # Multiplier of material density
    # # APFSDS_RodHardness = 3000  # # Brinell hardness of tungsten is between 2000 and 4000
    # # APFSDS_Velocity    = 1500  # # In Meters/second
    # # APFSDS_IsSolid     = 1     # # Solidity of penetrator
    
    "AP"     = array(0.96,  0.3, 0.12,     1,  7850,     1500,    900, 1),
    "APDS"   = array(0.96, 0.45, 0.12,   0.5, 19250,     2000,   1100, 1),
    "APFSDS" = array(0.96, 0.75, 0.12,  0.35, 19300,     3000,   1500, 1),
    "HEAT"   = array(0.96,  0.8, 0.12,  0.01,  8960,   35 / 2,   1500, 0), # # I have no idea what's the hardness of superplastic metal is. So i'll devide it's solid state hardness by 2 # #
    "HEATFS" = array(0.96,    1, 0.12, 0.005, 16600,   42 / 2,   2000, 0)  # # I have no idea what's the hardness of superplastic metal is. So i'll devide it's solid state hardness by 2 # #
)

runOnChat(1)

}

if (chatClk(owner()) | clk("autorun")) {

Message   = owner():lastSaid():explode(" ")
Command   = Message[1, string]
Parameter = Message[2, string]
Value1    = Message[3, string]:toNumber()
Value2    = Message[4, string]:toNumber()
Value3    = Message[5, string]:toNumber()

switch (Command) {
    case "!sim",
        simulateERA()
        
        hideChat(1)
    break
    
    case "!rod",
        switch (Parameter) {
            case "length",   APFSDS_Length      = Value1, printColor(vec(223), "APFSDS_Length set to: ", vec(255, 223, 0), Value1), break
            case "rodlng",   APFSDS_RodLng      = Value1, printColor(vec(223), "APFSDS_RodLng set to: ", vec(255, 223, 0), Value1),  break
            case "diameter", APFSDS_Diameter    = Value1, printColor(vec(223), "APFSDS_Diameter set to: ", vec(255, 223, 0), Value1),  break
            case "roddim",   APFSDS_RodDim      = Value1, printColor(vec(223), "APFSDS_RodDim set to: ", vec(255, 223, 0), Value1),  break
            case "density",  APFSDS_RodDensity  = Value1, printColor(vec(223), "APFSDS_RodDensity set to: ", vec(255, 223, 0), Value1),  break
            case "hardness", APFSDS_RodHardness = Value1, printColor(vec(223), "APFSDS_RodHardness set to: ", vec(255, 223, 0), Value1),  break
            case "velocity", APFSDS_Velocity    = Value1, printColor(vec(223), "APFSDS_Velocity set to: ", vec(255, 223, 0), Value1),  break
            
            case "direction",
                APFSDS_Direction  = vec(Value1, Value2, Value3):normalized()
                Impact_Angle = asin(abs(APFSDS_Direction:dot(ERA_Direction)))
                printColor(vec(223), "APFSDS_Direction set to: ", vec(255, 223, 0), "" + vec(Value1, Value2, Value3))
            break
            
            case "issolid",  APFSDS_IsSolid    = Value1, printColor(vec(223), "APFSDS_IsSolid set to: ", vec(255, 223, 0), Value1),  break
        }
        
        if (AutoRun) {simulateERA()}
        hideChat(1)
    break
    
    case "!era",
        switch (Parameter) {
            case "thickness", ERA_Thickness = Value1, printColor(vec(223), "ERA_Thickness set to: ", vec(255, 223, 0), Value1),  break
            case "density",   ERA_Density   = Value1, printColor(vec(223), "ERA_Density set to: ", vec(255, 223, 0), Value1),  break
            case "hardness",  ERA_Hardness  = Value1, printColor(vec(223), "ERA_Hardness set to: ", vec(255, 223, 0), Value1),  break
            case "velocity",  ERA_Velocity  = Value1, printColor(vec(223), "ERA_Velocity set to: ", vec(255, 223, 0), Value1),  break
            
            case "direction",
                ERA_Direction = vec(Value1, Value2, Value3):normalized()
                Impact_Angle = asin(abs(APFSDS_Direction:dot(ERA_Direction)))
                printColor(vec(223), "ERA_Direction set to: ", vec(255, 223, 0), "" + vec(Value1, Value2, Value3))
            break
        }
        
        if (AutoRun) {simulateERA()}
        hideChat(1)
    break
    
    case "!preset",
        
        APFSDS_Length      = Presets[Parameter, array][1, number]
        APFSDS_RodLng      = Presets[Parameter, array][2, number]
        APFSDS_Diameter    = Presets[Parameter, array][3, number]
        APFSDS_RodDim      = Presets[Parameter, array][4, number]
        APFSDS_RodDensity  = Presets[Parameter, array][5, number]
        APFSDS_RodHardness = Presets[Parameter, array][6, number]
        APFSDS_Velocity    = Presets[Parameter, array][7, number]
        APFSDS_IsSolid     = Presets[Parameter, array][8, number]
        
        printColor(vec(223), "Preset loaded ", vec(255, 223, 0), Parameter)
        
        if (AutoRun) {simulateERA()}
        hideChat(1)
    break
    
    case "!autorun",
        AutoRun = !AutoRun
        
        printColor(vec(223), "Autorun ", vec(255, 223, 0), AutoRun ? "Enabled" : "Disabled")
        hideChat(1)
    break
}

}