kingery-bulmash


Namekingery-bulmash JSON
Version 1.0.1 PyPI version JSON
download
home_pageNone
SummaryKingery-Bulmash Blast Wave Characteristics Calculator
upload_time2024-09-28 20:02:36
maintainerNone
docs_urlNone
authorfcento100
requires_python>=3.12
licenseMIT License Copyright (c) 2024 fcento100 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords tnt blast bulmash kingery
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Kingery-Bulmash Blast Wave Characteristics Calculator

Python implementation of the Simplified Kingery Airblast Formulas and Coefficients from: 

> #### Simplified Kingery Airblast Calculations
> Swisdak, Jr, Michael M.  
> NAVAL SURFACE WARFARE CENTER INDIAN HEAD DIV MD  
> 1994 Aug 01  
> Accession Number: [ADA526744](https://apps.dtic.mil/sti/pdfs/ADA526744.pdf)  
> Security Classification: UNCLASSIFIED    

Applicable for TNT equivalent NEQ (Net Explosive Quantity) and hemispherical surface bursts.

## Installation

Using pip to install from [PyPI](https://pypi.org/project/kingery-bulmash/):

```bash
pip install kingery-bulmash
```

## Usage

```python
import kingery_bulmash as kb
```
Use prefix `kb.` to import all required objects. An example for a TNT eqivalent NEQ of 10,000 kg at 500 m:

```python
import kingery_bulmash as kb

# for metric units: 10000kg at 500m
res = kb.Blast_Parameters(unit_system=kb.Units.METRIC, 
                          neq=10000, 
                          distance=500)

print(res)
```
<details>
<summary>Expand to see console output</summary>

```python
Blast Parameters (Kingery-Bulmash)
NEQ: 10000 kg
Distance: 500 m
Time of Arrival: 1276.1650108864796 ms
Incident Pressure: 5.0549639655028455 kPa
Reflected Pressure: 10.244621193146642 kPa
Positive Phase Duration: 133.23344980362697 ms
Incident Impulse: 295.87689480141484 kPa-ms
Reflected Impulse: 1063.0270073779907 kPa-ms
Shock Front Velocity: 347.3295095310771 m/s
```
</details>

## kb.Units

The `kb.Units` *Enum* is how we select the units for the calculation, it needs to be passed to `kb.Blast_Parameters` as either `kb.Units.METRIC` or `kb.Units.IMPERIAL`. 

- `kb.Units.METRIC` 
    > for **neq** in *kg* and **distance**  in *m*.
- `kb.Units.IMPERIAL`
    > for **neq** in *lb* and **distance**  in *ft*.

> [!IMPORTANT]
> The library does not convert between units. Rather, it uses the metric and imperial parameters from the paper directly, therefore there might be slight differences between the results. 

## kb.Blast_Parameters

### ***class*** kb.Blast_Parameters(***unit_system***, ***neq***, ***distance***, ***safe**=True*)

The `Blast_Parameters` *dataclass* calculates all the Kingery-Bulmash parameters from the paper. 

Attributes:

- **unit_system** : ***kb.Units.METRIC*** or ***kb.Units.IMPERIAL***
    > Defines the unit system of the imput and calculated results. See `kb.Units` section [here](#kbUnits).

- **neq**: *float*
    > TNT equivalent net explosive quantity. **kg** or **lb** based on **unit_system**.

- **distance**: *float*
    > Distance from the explosive. **m** or **ft** based on **unit_system**.
 
 - **safe**: *bool, optional*
    > When `True` (default), `kb.Blast_Parameters` will raise a `ValueError` if any *attribute* is out of range. When `False` any *attribute* out of range will be set to `None` without raising a `ValueError`, this allows to significantly expand the range of values for less sensitive attributes. Default is `True`.

> [!TIP]
> `Blast_Parameters` can raise `Exception` and `ValueError`, it is recommended to use `try` and `except` to handle this this behaviour. [Python Errors Tutorial](https://docs.python.org/3/tutorial/errors.html).

\_\_post_init__ attributes:

- **time_of_arrival**: *float, None*
    > Time of arrival in **ms**.
- **incident_pressure**: *float, None*
    > Incident pressure in **kPa** or **psi** based on **unit_system**.
- **reflected_pressure**: *float, None*
    > Reflected pressure in **kPa** or **psi** based on **unit_system**.
- **positive_phase_duration**: *float, None*
    > Positive phase duration in **ms**.
- **incident_impulse**: *float, None*
    > Incident inpulse in **kPa-ms** or **psi-ms** based on **unit_system**.
- **reflected_impulse**: *float, None*
    > Reflected impulse in **kPa-ms** or **psi-ms** based on **unit_system**.
- **shock_front_velocity**: *float, None*
    > Shock front velocity in **m/s** or **ft/s** based on **unit_system**.
- **all_units**: *dict*
    > Dictionary containing *key: value* pairs where the *key* is the attribute name as a `str` and the *value* is the unit as `str`.

Methods:

- **to_dict**()
    > Returns a `dict` representation of the *dataclass*
- **\_\_repr__**()
    > Inherits the default *dataclass* behaviour
- **\_\_str__**()
    > "Pretty" representation of the data as `str`

## Examples:

### Example 1: Single Attribute
```python
import kingery_bulmash as kb

res = kb.Blast_Parameters(unit_system=kb.Units.METRIC, 
                          neq=10000, 
                          distance=500, 
                          safe=True)

#getting only incident pressure
pr = res.incident_pressure

#getting the units of incident pressure
pr_u = res.all_units['incident_pressure']

print(pr, pr_u)
```

<details>
<summary>Expand to see console output</summary>

```python
5.0549639655028455 kPa
```
</details>

### Example 2: Loop Over Range (safe=False)

In this example we set `safe=False` as the range of scaled distances allowed by *incident_impulse* is larger than *shock_front_velocity* which would cause a `ValueError` sooner if `safe=True`. `Try` and `except` used to handle when distance is 0. 

```python
import kingery_bulmash as kb

NEQ = 5000
for dist in range(0, 10000, 1000):
    try:
        RES = kb.Blast_Parameters(unit_system=kb.Units.IMPERIAL,
                                  neq=NEQ,
                                  distance=dist,
                                  safe=False)
        
        i_imp = RES.incident_impulse
        i_imp_u = RES.all_units["incident_impulse"]
        
        print(f'{dist} ft: {i_imp} {i_imp_u}')
    
    except ValueError as err:
        print(f'{dist} ft: {err}')
```

<details>
<summary>Expand to see console output</summary>

```python
0 ft: 'distance' must be > 0.
1000 ft: 26.167261959845302 psi-ms
2000 ft: 12.835212556333252 psi-ms
3000 ft: 8.344381432625331 psi-ms
4000 ft: 6.147651070542891 psi-ms
5000 ft: 4.8505476573514335 psi-ms
6000 ft: 3.99668842429768 psi-ms
7000 ft: None psi-ms
8000 ft: None psi-ms
9000 ft: None psi-ms
```
</details>

## Build/Install/Test From Source

The build-system is [Hatch](https://hatch.pypa.io/latest/).

To build and install from source, clone the repository and in the root folder run:
```bash
hatch build
```
To install with pip, also from the root folder, run:

```bash
pip install dist\kingery_bulmash-X.X.X-py3-none-any.whl
```
Adjust the file name/path accordingly.

To run tests:

```bash
hatch test
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "kingery-bulmash",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.12",
    "maintainer_email": null,
    "keywords": "TNT, blast, bulmash, kingery",
    "author": "fcento100",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/e4/73/2006ebcb3ed4c05d86b18e23f8d71f32a7894020f3a5b697f42d9ccbcef5/kingery_bulmash-1.0.1.tar.gz",
    "platform": null,
    "description": "# Kingery-Bulmash Blast Wave Characteristics Calculator\n\nPython implementation of the Simplified Kingery Airblast Formulas and Coefficients from: \n\n> #### Simplified Kingery Airblast Calculations\n> Swisdak, Jr, Michael M.  \n> NAVAL SURFACE WARFARE CENTER INDIAN HEAD DIV MD  \n> 1994 Aug 01  \n> Accession Number: [ADA526744](https://apps.dtic.mil/sti/pdfs/ADA526744.pdf)  \n> Security Classification: UNCLASSIFIED    \n\nApplicable for TNT equivalent NEQ (Net Explosive Quantity) and hemispherical surface bursts.\n\n## Installation\n\nUsing pip to install from [PyPI](https://pypi.org/project/kingery-bulmash/):\n\n```bash\npip install kingery-bulmash\n```\n\n## Usage\n\n```python\nimport kingery_bulmash as kb\n```\nUse prefix `kb.` to import all required objects. An example for a TNT eqivalent NEQ of 10,000 kg at 500 m:\n\n```python\nimport kingery_bulmash as kb\n\n# for metric units: 10000kg at 500m\nres = kb.Blast_Parameters(unit_system=kb.Units.METRIC, \n                          neq=10000, \n                          distance=500)\n\nprint(res)\n```\n<details>\n<summary>Expand to see console output</summary>\n\n```python\nBlast Parameters (Kingery-Bulmash)\nNEQ: 10000 kg\nDistance: 500 m\nTime of Arrival: 1276.1650108864796 ms\nIncident Pressure: 5.0549639655028455 kPa\nReflected Pressure: 10.244621193146642 kPa\nPositive Phase Duration: 133.23344980362697 ms\nIncident Impulse: 295.87689480141484 kPa-ms\nReflected Impulse: 1063.0270073779907 kPa-ms\nShock Front Velocity: 347.3295095310771 m/s\n```\n</details>\n\n## kb.Units\n\nThe `kb.Units` *Enum* is how we select the units for the calculation, it needs to be passed to `kb.Blast_Parameters` as either `kb.Units.METRIC` or `kb.Units.IMPERIAL`. \n\n- `kb.Units.METRIC` \n    > for **neq** in *kg* and **distance**  in *m*.\n- `kb.Units.IMPERIAL`\n    > for **neq** in *lb* and **distance**  in *ft*.\n\n> [!IMPORTANT]\n> The library does not convert between units. Rather, it uses the metric and imperial parameters from the paper directly, therefore there might be slight differences between the results. \n\n## kb.Blast_Parameters\n\n### ***class*** kb.Blast_Parameters(***unit_system***, ***neq***, ***distance***, ***safe**=True*)\n\nThe `Blast_Parameters` *dataclass* calculates all the Kingery-Bulmash parameters from the paper. \n\nAttributes:\n\n- **unit_system** : ***kb.Units.METRIC*** or ***kb.Units.IMPERIAL***\n    > Defines the unit system of the imput and calculated results. See `kb.Units` section [here](#kbUnits).\n\n- **neq**: *float*\n    > TNT equivalent net explosive quantity. **kg** or **lb** based on **unit_system**.\n\n- **distance**: *float*\n    > Distance from the explosive. **m** or **ft** based on **unit_system**.\n \n - **safe**: *bool, optional*\n    > When `True` (default), `kb.Blast_Parameters` will raise a `ValueError` if any *attribute* is out of range. When `False` any *attribute* out of range will be set to `None` without raising a `ValueError`, this allows to significantly expand the range of values for less sensitive attributes. Default is `True`.\n\n> [!TIP]\n> `Blast_Parameters` can raise `Exception` and `ValueError`, it is recommended to use `try` and `except` to handle this this behaviour. [Python Errors Tutorial](https://docs.python.org/3/tutorial/errors.html).\n\n\\_\\_post_init__ attributes:\n\n- **time_of_arrival**: *float, None*\n    > Time of arrival in **ms**.\n- **incident_pressure**: *float, None*\n    > Incident pressure in **kPa** or **psi** based on **unit_system**.\n- **reflected_pressure**: *float, None*\n    > Reflected pressure in **kPa** or **psi** based on **unit_system**.\n- **positive_phase_duration**: *float, None*\n    > Positive phase duration in **ms**.\n- **incident_impulse**: *float, None*\n    > Incident inpulse in **kPa-ms** or **psi-ms** based on **unit_system**.\n- **reflected_impulse**: *float, None*\n    > Reflected impulse in **kPa-ms** or **psi-ms** based on **unit_system**.\n- **shock_front_velocity**: *float, None*\n    > Shock front velocity in **m/s** or **ft/s** based on **unit_system**.\n- **all_units**: *dict*\n    > Dictionary containing *key: value* pairs where the *key* is the attribute name as a `str` and the *value* is the unit as `str`.\n\nMethods:\n\n- **to_dict**()\n    > Returns a `dict` representation of the *dataclass*\n- **\\_\\_repr__**()\n    > Inherits the default *dataclass* behaviour\n- **\\_\\_str__**()\n    > \"Pretty\" representation of the data as `str`\n\n## Examples:\n\n### Example 1: Single Attribute\n```python\nimport kingery_bulmash as kb\n\nres = kb.Blast_Parameters(unit_system=kb.Units.METRIC, \n                          neq=10000, \n                          distance=500, \n                          safe=True)\n\n#getting only incident pressure\npr = res.incident_pressure\n\n#getting the units of incident pressure\npr_u = res.all_units['incident_pressure']\n\nprint(pr, pr_u)\n```\n\n<details>\n<summary>Expand to see console output</summary>\n\n```python\n5.0549639655028455 kPa\n```\n</details>\n\n### Example 2: Loop Over Range (safe=False)\n\nIn this example we set `safe=False` as the range of scaled distances allowed by *incident_impulse* is larger than *shock_front_velocity* which would cause a `ValueError` sooner if `safe=True`. `Try` and `except` used to handle when distance is 0. \n\n```python\nimport kingery_bulmash as kb\n\nNEQ = 5000\nfor dist in range(0, 10000, 1000):\n    try:\n        RES = kb.Blast_Parameters(unit_system=kb.Units.IMPERIAL,\n                                  neq=NEQ,\n                                  distance=dist,\n                                  safe=False)\n        \n        i_imp = RES.incident_impulse\n        i_imp_u = RES.all_units[\"incident_impulse\"]\n        \n        print(f'{dist} ft: {i_imp} {i_imp_u}')\n    \n    except ValueError as err:\n        print(f'{dist} ft: {err}')\n```\n\n<details>\n<summary>Expand to see console output</summary>\n\n```python\n0 ft: 'distance' must be > 0.\n1000 ft: 26.167261959845302 psi-ms\n2000 ft: 12.835212556333252 psi-ms\n3000 ft: 8.344381432625331 psi-ms\n4000 ft: 6.147651070542891 psi-ms\n5000 ft: 4.8505476573514335 psi-ms\n6000 ft: 3.99668842429768 psi-ms\n7000 ft: None psi-ms\n8000 ft: None psi-ms\n9000 ft: None psi-ms\n```\n</details>\n\n## Build/Install/Test From Source\n\nThe build-system is [Hatch](https://hatch.pypa.io/latest/).\n\nTo build and install from source, clone the repository and in the root folder run:\n```bash\nhatch build\n```\nTo install with pip, also from the root folder, run:\n\n```bash\npip install dist\\kingery_bulmash-X.X.X-py3-none-any.whl\n```\nAdjust the file name/path accordingly.\n\nTo run tests:\n\n```bash\nhatch test\n```\n",
    "bugtrack_url": null,
    "license": "MIT License\n        \n        Copyright (c) 2024 fcento100\n        \n        Permission is hereby granted, free of charge, to any person obtaining a copy\n        of this software and associated documentation files (the \"Software\"), to deal\n        in the Software without restriction, including without limitation the rights\n        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n        copies of the Software, and to permit persons to whom the Software is\n        furnished to do so, subject to the following conditions:\n        \n        The above copyright notice and this permission notice shall be included in all\n        copies or substantial portions of the Software.\n        \n        THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n        SOFTWARE.",
    "summary": "Kingery-Bulmash Blast Wave Characteristics Calculator",
    "version": "1.0.1",
    "project_urls": {
        "Homepage": "https://github.com/fcento100/kingery-bulmash",
        "Issues": "https://github.com/fcento100/kingery-bulmash/issues"
    },
    "split_keywords": [
        "tnt",
        " blast",
        " bulmash",
        " kingery"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "50b080c94e339a28ac65ed05886e8cc2621000d20d7565781336b7d4f7b98047",
                "md5": "89cf57d157e1fb2896135131354cbc6a",
                "sha256": "4862bb39db1ddcbe6dc5bd0f53bbeb6a6431f2cfc6c7c0fe5c6c78bf53f027dd"
            },
            "downloads": -1,
            "filename": "kingery_bulmash-1.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "89cf57d157e1fb2896135131354cbc6a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.12",
            "size": 8301,
            "upload_time": "2024-09-28T20:02:34",
            "upload_time_iso_8601": "2024-09-28T20:02:34.567255Z",
            "url": "https://files.pythonhosted.org/packages/50/b0/80c94e339a28ac65ed05886e8cc2621000d20d7565781336b7d4f7b98047/kingery_bulmash-1.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "e4732006ebcb3ed4c05d86b18e23f8d71f32a7894020f3a5b697f42d9ccbcef5",
                "md5": "4af359dee7e1088efea97fd9b209bdd3",
                "sha256": "f6d0a682e3aa227aa23544c5b2d62d12f51e0aeaaa08515c94929b4de8e7833f"
            },
            "downloads": -1,
            "filename": "kingery_bulmash-1.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "4af359dee7e1088efea97fd9b209bdd3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.12",
            "size": 12923,
            "upload_time": "2024-09-28T20:02:36",
            "upload_time_iso_8601": "2024-09-28T20:02:36.091017Z",
            "url": "https://files.pythonhosted.org/packages/e4/73/2006ebcb3ed4c05d86b18e23f8d71f32a7894020f3a5b697f42d9ccbcef5/kingery_bulmash-1.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-28 20:02:36",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "fcento100",
    "github_project": "kingery-bulmash",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "kingery-bulmash"
}
        
Elapsed time: 4.51701s