Skip to content

UniFormal/physics

Repository files navigation

Physical MPD Models MMT Extension

About

Provides build targets for physical models formulated in MMT.

Extract model statistics

To load the extension for exporting MMT model theories into python, run in the mmt shell:

extension uniformal.physics.MPDStatsExporter  

and then proceed to generate statistics files corresponding to the theories with:

build MitM/Models mpd-stats

Currently, the files will contain functional cycles present in the models.

Python

To load the extension for exporting MMT model theories into python, run in the mmt shell:

extension uniformal.physics.PythonExporter  

and then proceed to generate python files corresponding to the theories with:

build MitM/Models mpd-python  

As an example, a toy model was written in VanRoosbrockEg.mmt. The generated python file is VanRoosbrockEg.py. One can immediately attempt iterative methods like Gauss-Seidel to solve for the electric displacement $D$ using the cycle labeled cycle1:

import VanRoosbrockEg
from mpdbase import *
import numpy as np

model = VanRoosbrockEg.MPD_VanRoosbrockEg(np.linspace(0, 0.5, 10))
state = MPDState(model)
state.gauss_seidel("cycle1", epsilon=1e-3)
print(state)

In general, from the Model object, one has access to the laws of the Model using model['law_name'] and the quantities using model.quantity_name. For instance, one can compute evaluate the law gauss_law and assign it to the current value of charge_density in the state:

state.charge_density = model['gauss_law'].charge_density(state)

The model object also provides with a method to generate a rough MPD plot of the model:

model.plot_mpd_graphic()

generates:

https://i.imgur.com/tXA3dXP.png

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published