vtmmpy


Namevtmmpy JSON
Version 1.0.10 PyPI version JSON
download
home_pagehttps://github.com/AI-Tony/vtmmpy/tree/main
SummaryA vectorized implementation of the transfer matrix method
upload_time2023-05-16 14:07:36
maintainer
docs_urlNone
authorTony
requires_python>=3.6,<4.0
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # **Vectorized Transfer Matrix Method Python** 
The transfer matrix method (TMM) is an analytic approach for obtaining the reflection and transmission coefficients in stratified media. vtmmpy is a vectorised implementation of the TMM written in Python. It has a focus on speed and ease of use. 

![](https://github.com/AI-Tony/vtmmpy/blob/main/images/MTM.png?raw=true) 

### **Installation**

---

```
pip install vtmmpy 
```

### **Usage**

--- 

Import the vtmmpy module.

```
import vtmmpy
```

Create an instance of the ```TMM``` class. 

```
freq = np.linspace(170, 210, 30) 
theta = np.array(0, 60, 60) 

tmm = vtmmpy.TMM(freq, 
                theta, 
                f_scale=1e12, 
                l_scale=1e-9, 
                incident_medium="air", 
                transmitted_medium="air") 
```

- freq: a numpy array representing the spectral range of interest. 
- theta: a numpy array of one or more angles of incidence. 
- f_scale (optional): input frequency scale, default is terahertz.
- l_scale (optional): input length scale, default is nanometers.
- incident_medium (optional): incident medium, default is air.
- transmitted_medium (optional): transmitted medium, default is air. 

Add multilayer metamaterial designs with the ```addDesign()``` method. 

```
materials   = ["Ag", "SiO2", "Ag", "SiO2", "Ag", "SiO2"] 
thicknesses = [15, 85, 15, 85, 15, 85] 

tmm.addDesign(materials, thicknesses)
```

- materials: list of materials 
- thicknesses: list of the corresponding material thicknesses 

Internally, vtmmpy uses the [regidx](https://gitlab.com/benvial/refidx) Python package to download refractive index data from [refractiveindex.info](https://refractiveindex.info/) for your choosen materials and spectral range. At this point, you will be presented with a few options corresponding to the data source ("Page" dropdown on refractiveindex.info). Study these carefully and refer to [refractiveindex.info](https://refractiveindex.info/) for more detailed information about how the data were obtained. Your choice here could greatly impact the accuracy of your results.

Optionally call the ```summary()``` and/or ```designs()``` methods to view the data currently held by the instance.

```
tmm.summary() 
tmm.designs() 
```

Additionally, the ```tmm.opticalProperties()``` method can be used to obtain a dictionary of optical properties of the materials entered in the frequency range specified.

```
props = tmm.opticalProperties()

print(props.keys()) # output: dict_keys(['air', 'SiO2', 'Ag'])
print(props["Ag"]["n"]) # ouput is the refractive index of Ag
print(props["Ag"]["beta"]) # ouput is the propagation constant of Ag
```

Calculate the reflection/transmission coefficients by calling the appropriate method. You should specify wether you want the transverse magnetic/electric polarization by supplying the "TM" or "TE" flag, respectively.

```
RTM = tmm.reflection("TM") 
RTE = tmm.reflection("TE") 
TTM = tmm.transmission("TM") 
TTE = tmm.transmission("TE") 
```

Tips: 
 - The ```reflection()``` and ```transmission()``` methods return both complex parts. Use Python's built-in ```abs()``` function to obtain the magnitude.
 - The intensity is the square of the magnitude (eg. ```abs(reflection("TM"))**2```). 
 - ```reflection()``` and ```transmission()``` return an ndarray with a minimum of 2 dimensions. The first dimension always corresponds to the number of designs. Therefore, when printing/plotting results, you must always index the first dimension (even if you only have 1 design). 

### **Examples**

--- 



![](https://github.com/AI-Tony/vtmmpy/blob/main/images/2dplots.png?raw=true)


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/AI-Tony/vtmmpy/tree/main",
    "name": "vtmmpy",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6,<4.0",
    "maintainer_email": "",
    "keywords": "",
    "author": "Tony",
    "author_email": "tk_87@hotmail.com",
    "download_url": "https://files.pythonhosted.org/packages/bc/06/99e9f52c0e3599d8fd408b10cbfaac87dfdd43da976450044ceb247cb67e/vtmmpy-1.0.10.tar.gz",
    "platform": null,
    "description": "# **Vectorized Transfer Matrix Method Python** \nThe transfer matrix method (TMM) is an analytic approach for obtaining the reflection and transmission coefficients in stratified media. vtmmpy is a vectorised implementation of the TMM written in Python. It has a focus on speed and ease of use. \n\n![](https://github.com/AI-Tony/vtmmpy/blob/main/images/MTM.png?raw=true) \n\n### **Installation**\n\n---\n\n```\npip install vtmmpy \n```\n\n### **Usage**\n\n--- \n\nImport the vtmmpy module.\n\n```\nimport vtmmpy\n```\n\nCreate an instance of the ```TMM``` class. \n\n```\nfreq = np.linspace(170, 210, 30) \ntheta = np.array(0, 60, 60) \n\ntmm = vtmmpy.TMM(freq, \n                theta, \n                f_scale=1e12, \n                l_scale=1e-9, \n                incident_medium=\"air\", \n                transmitted_medium=\"air\") \n```\n\n- freq: a numpy array representing the spectral range of interest. \n- theta: a numpy array of one or more angles of incidence. \n- f_scale (optional): input frequency scale, default is terahertz.\n- l_scale (optional): input length scale, default is nanometers.\n- incident_medium (optional): incident medium, default is air.\n- transmitted_medium (optional): transmitted medium, default is air. \n\nAdd multilayer metamaterial designs with the ```addDesign()``` method. \n\n```\nmaterials   = [\"Ag\", \"SiO2\", \"Ag\", \"SiO2\", \"Ag\", \"SiO2\"] \nthicknesses = [15, 85, 15, 85, 15, 85] \n\ntmm.addDesign(materials, thicknesses)\n```\n\n- materials: list of materials \n- thicknesses: list of the corresponding material thicknesses \n\nInternally, vtmmpy uses the [regidx](https://gitlab.com/benvial/refidx) Python package to download refractive index data from [refractiveindex.info](https://refractiveindex.info/) for your choosen materials and spectral range. At this point, you will be presented with a few options corresponding to the data source (\"Page\" dropdown on refractiveindex.info). Study these carefully and refer to [refractiveindex.info](https://refractiveindex.info/) for more detailed information about how the data were obtained. Your choice here could greatly impact the accuracy of your results.\n\nOptionally call the ```summary()``` and/or ```designs()``` methods to view the data currently held by the instance.\n\n```\ntmm.summary() \ntmm.designs() \n```\n\nAdditionally, the ```tmm.opticalProperties()``` method can be used to obtain a dictionary of optical properties of the materials entered in the frequency range specified.\n\n```\nprops = tmm.opticalProperties()\n\nprint(props.keys()) # output: dict_keys(['air', 'SiO2', 'Ag'])\nprint(props[\"Ag\"][\"n\"]) # ouput is the refractive index of Ag\nprint(props[\"Ag\"][\"beta\"]) # ouput is the propagation constant of Ag\n```\n\nCalculate the reflection/transmission coefficients by calling the appropriate method. You should specify wether you want the transverse magnetic/electric polarization by supplying the \"TM\" or \"TE\" flag, respectively.\n\n```\nRTM = tmm.reflection(\"TM\") \nRTE = tmm.reflection(\"TE\") \nTTM = tmm.transmission(\"TM\") \nTTE = tmm.transmission(\"TE\") \n```\n\nTips: \n - The ```reflection()``` and ```transmission()``` methods return both complex parts. Use Python's built-in ```abs()``` function to obtain the magnitude.\n - The intensity is the square of the magnitude (eg. ```abs(reflection(\"TM\"))**2```). \n - ```reflection()``` and ```transmission()``` return an ndarray with a minimum of 2 dimensions. The first dimension always corresponds to the number of designs. Therefore, when printing/plotting results, you must always index the first dimension (even if you only have 1 design). \n\n### **Examples**\n\n--- \n\n\n\n![](https://github.com/AI-Tony/vtmmpy/blob/main/images/2dplots.png?raw=true)\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "A vectorized implementation of the transfer matrix method",
    "version": "1.0.10",
    "project_urls": {
        "Homepage": "https://github.com/AI-Tony/vtmmpy/tree/main",
        "Repository": "https://github.com/AI-Tony/vtmmpy/tree/main"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "028ff1dc83849ecf284963ed1cbb87696415ef1654bc771951e7c0c47f1183a4",
                "md5": "b79eb9e5ff6b50047a0173e46e195e9b",
                "sha256": "1edc48fdd77fdfbee69045f65592d09617f4aff499c7395a29baa7ec67c9104e"
            },
            "downloads": -1,
            "filename": "vtmmpy-1.0.10-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b79eb9e5ff6b50047a0173e46e195e9b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6,<4.0",
            "size": 17256,
            "upload_time": "2023-05-16T14:07:26",
            "upload_time_iso_8601": "2023-05-16T14:07:26.126846Z",
            "url": "https://files.pythonhosted.org/packages/02/8f/f1dc83849ecf284963ed1cbb87696415ef1654bc771951e7c0c47f1183a4/vtmmpy-1.0.10-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bc0699e9f52c0e3599d8fd408b10cbfaac87dfdd43da976450044ceb247cb67e",
                "md5": "ac8257fa4fa0366bcf4fd420272a631f",
                "sha256": "fed853252208ae18aeaf714abb9984197a3bc557e98af672d7d1e472afe60622"
            },
            "downloads": -1,
            "filename": "vtmmpy-1.0.10.tar.gz",
            "has_sig": false,
            "md5_digest": "ac8257fa4fa0366bcf4fd420272a631f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6,<4.0",
            "size": 16647,
            "upload_time": "2023-05-16T14:07:36",
            "upload_time_iso_8601": "2023-05-16T14:07:36.067600Z",
            "url": "https://files.pythonhosted.org/packages/bc/06/99e9f52c0e3599d8fd408b10cbfaac87dfdd43da976450044ceb247cb67e/vtmmpy-1.0.10.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-16 14:07:36",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "AI-Tony",
    "github_project": "vtmmpy",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "vtmmpy"
}
        
Elapsed time: 0.12825s