Giter Site home page Giter Site logo

qmt's Introduction

Qubit Modeling Tools (QMT)

Build Status

Welcome to our qubit modeling tools (qmt)! This package is designed to automate the setup of complex geometries appropriate to physical qubit simulations. This package is licensed with an MIT open source license.

Getting Started

If you're only using qmt without making code changes, you can use docker. See Wiki link.

If you're developing qmt, it is advisable to set it up with conda instead. See Conda Setup for detailed instructions.

A significant part of the repository consists of Python functions and macros to be executed within FreeCAD, either interactively or in batch mode. These require the latest version of FreeCAD (0.18), which works with Python 3.

Note that this initial release does not contain examples or introductory documentation, which we plan to add in time. If you want to get started, feel free to email John Gamble at [email protected].

Development notes

We are using GitHub Flow for the development of this code. Please see here for a tutorial.

This project uses black to improve code readability and to make changesets more readable. The package is included with the conda environment, and you can run it with black [path_to_qmt] -t py36. There's an included pre-commit hook that automatically formats your code on commit. It also integrates with popular IDEs such as PyCharm and VSCode.

Contributing

This project welcomes contributions and suggestions, but please coordinate with the maintainers before setting out to implement significant changes or new features. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repositories using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

qmt's People

Contributors

adamfrees avatar aeantipov avatar agarwalrounak avatar basnijholt avatar cclauss avatar donjan avatar georgwinkler avatar jgukelberger avatar johnkgamble avatar kant avatar kvanhoogdalem avatar merrittlosert avatar microsoftopensource avatar msftgits avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

qmt's Issues

test_geo_task broken

@donjan - it looks like test_geo_task broke in your latest patches. Does it run for you? I get a non-descriptive segfault now.

It might have to do with that you removed my explicit setting of the python 2 environment in favor of something fancier? I have confirmed that rolling back past your changes fixes things. If we can't figure this out soon, please revert, as that test is a critical safety net. Thanks!

environment_min.yml is broken

I've just installed this environment and it resulted in a broken kwant:

>>> import kwant
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/w2scratch/home/t-banij/miniconda3/envs/py36/lib/python3.6/site-packages/kwant/__init__.py", line 37, in <module>
    exec('from . import {0}'.format(module))
  File "<string>", line 1, in <module>
  File "/w2scratch/home/t-banij/miniconda3/envs/py36/lib/python3.6/site-packages/kwant/builder.py", line 20, in <module>
    from .linalg import lll
  File "/w2scratch/home/t-banij/miniconda3/envs/py36/lib/python3.6/site-packages/kwant/linalg/__init__.py", line 10, in <module>
    from . import lapack
ImportError: libgfortran.so.4: cannot open shared object file: No such file or directory

Proposal assertion of units, in view of QMT/QMS refactor

I think it might be useful to use assertions to make sure that parameters in functions are of the correct unit. Right now, if a user fails to provide the correct units, an error appears during the to_float routine. Do you guys agree this might be useful?

P.S. Below you will find some code I wrote to check whether a variable is of the correct unit. Since I am still quite unfamiliar with the codebase, I didn't know where to put it and so I didn't make it into a pull request.

from sympy.core.mul import Mul
import sympy.core
from qmt.physics_constants import UArray

def is_correct_unit(s, desired_unit):
    if isinstance(s, Mul):
        return type(s/desired_unit) is sympy.numbers.Float
    
    elif isinstance(s, UArray):
        return s.unit is desired_unit
    
    else:
        return s == 0
        
print(is_correct_unit(0.25* physics_constants.units.V,  physics_constants.units.V))
print(is_correct_unit(UArray(np.array([0, 1, 2]), unit=physics_constants.units.V), physics_constants.units.V))
        
print(is_correct_unit(0.25,  physics_constants.units.V))
print(is_correct_unit(UArray(np.array([0, 1, 2])), physics_constants.units.V))

Fix build order in tasks

The build order in the tasks branch is a bit weird now, and we need to be more careful since subtract lists are deprecated. We currently have:

[A,B,C] -> A overwrites B, overwrites C

However, if lithography is introduced into things, it's a little more complex:

[A,B,C,L1,L2] -> A,B,C builds as before, but then L1 and L2 are lithography layers on top.

This is a little goofy, since the lithography needs to come last (otherwise it complains about the base layers not being in place). However, non-lithographic layers listed last have lowest priority. I'd recommend reordering things so that they look like this:

[C,B,A,L1,L2],

where the overwrite precedence is left to write (so that L2 is highest priority and C is lowest). Does that makes sense? Would it be easy to do?

Unwanted imports

  • QMT is currently importing QMS, which should not occur. (qmt/tasks/ms/mesh.py, qmt/data/scalar_data.py, qmt/geometry/freecad/run.py)
    These should be QMT dummies.

  • fenics is getting imported in the global namespace of some files, which makes it a dependency for QMT. (qmt/data/scalar_data.py, qmt/data/geo_data.py)
    We probably want to push it down to function level imports, and remove where possible.

  • the unit tests are failing due to fenics not being installed in Travis. Either remove fenics imports or add it as a dependency.

setup.py is broken

pip install . should install all Python dependencies, which doesn't happen ATM.

Adding a requirements.txt file (as is standard) like:

numpy
scipy
matplotlib
pytest
future
pytablewriter

and doing this inside setup.py

with open('requirements.txt') as f:
    requirements = [x.strip() for x in f.readlines()]

setup(
    ...
    install_requires=requirements,
)

would fix this issue.

freecad_dict format

About the dictionary we use to feed Geometry3D.

A

Recently we changed from file_path to serial_fcdoc. This means instead of

freecad_dict = {
    'pyenv': 'python2',
    'file_path': 'geometry_sweep_showcase.fcstd'
}

the user has to write

freecad_dict = {
    'pyenv': 'python2',
    'serial_fcdoc': Geometry3D.serialize_fc_file('geometry_sweep_showcase.fcstd')
}
  1. Is the template doc required to be serialised? Might be a future proof choice in case it is not transfered on disk anymore, so I agree with that.
  2. Is the doc required to be serialised by the user? We could call serialize_fc_file in the Geometry3D.__init__, then the user can write the more convenient top snippet.

On a related note, we have that kind of serialisation code in various places (qmt/geometry/freecad/fileIO.py, qmt/data/geo_data.py and now qmt/tasks/geometry.py). What would be a good place that is importable by Python2 and Python3, to hold a set of unified "deal with pipeable serial data" functions?

B

The Geometry3D docstring states that the dict requires

"parts_dict": parts_dict = {part_name: Part3D}

The current implementation is

"input_parts":input_parts_list = [Part3D]

Since Geometry3D "consumes" (or is at least the sole user of) these parts, and the returned geo object contains the part names, why is there a need to set part_name at this point?

I plan to remove parts_dict and document input_parts as the build order spec.

Bare asterisk signatures

ThomasFermiData.__init__(self,*,... is nice in principle, but doesn't work in Python2.
For some reason thomas_fermi_data.py gets loaded during a Python2 geometry building unpickle:

  File "/home/donjan/ETH/PhD/code/qmt/qmt/geometry/freecad/run.py", line 19, in main
    data = pickle.loads(''.join(sys.stdin.readlines()))
  File "/usr/lib/python2.7/pickle.py", line 1388, in loads
    return Unpickler(file).load()
  File "/usr/lib/python2.7/pickle.py", line 864, in load
    dispatch[key](self)
  File "/usr/lib/python2.7/pickle.py", line 1096, in load_global
    klass = self.find_class(module, name)
  File "/usr/lib/python2.7/pickle.py", line 1130, in find_class
    __import__(module)
  File "/home/donjan/ETH/PhD/code/qmt/qmt/data/__init__.py", line 8, in <module>
    from .thomas_fermi_data import ThomasFermiData

Either break the dependency chain of ThomasFermiData in data/__init__.py or don't use bare asterisk kwargs enforcement in the init sig.
EDIT: or force pickle to not try to find this class?

QMS

I came across this repository and was reviewing the code. I notice the library qms is imported several times, but little documentation is provided. Would I be correct in assuming this is a proprietary Microsoft Python library for implementing ''quantum'' simulations in the Comsol? If so, is there a plan to open source this work?

Regards,
Thomas

Pickle load error in QMT example notebook

In qmt/examples/simple_notebook/simple_wire.ipynb, when trying to run the following cell:

with open('tf_data.pkl','rb') as file:
    tf_data = pickle.load(file)

I get this error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-13-3d0037a7086c> in <module>
      1 with open('tf_data.pkl','rb') as file:
----> 2     tf_data = pickle.load(file)

~/qmt/qmt/physics_constants.py in __setstate__(self, state)
    200         self.unit = state[-1]  # Set the unit attribute
    201         # Call the parent's __setstate__ with the other tuple elements.
--> 202         super(UArray, self).__setstate__(state[0:-1])
    203 
    204 

TypeError: __setstate__() argument 1, item 0 must be tuple, not int

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.