Skip to main content

No project description provided

Project description

zincware PyPI version 'Threejs

ZnDraw

Install via pip install zndraw. If you have pip install pywebview installed, ZnDraw will open in a dedicated window.

CLI

You can use ZnDraw with the CLI zndraw atoms.xyz. Alternatively, you can use zndraw from within a Juypter Notebook

from zndraw import ZnDraw
import ase

zndraw = ZnDraw()

zndraw
# this will show you the molecule

# new cell
zndraw.socket.sleep(2) # give it some time to fully connect
zndraw[0] = ase.Atoms(
  "H2O", positions=[[0.75, -0.75, 0], [0.75, 0.75, 0], [0, 0, 0]]
  )

or a normal Python script using zndraw = ZnDraw(jupyter=False) to open a browser window.

ZnDraw is designed to work with your Python scripts. To interface you can inherit from zndraw.examples.UpdateScene or follow this base class:

import abc
from pydantic import BaseModel

class UpdateScene(BaseModel, abc.ABC):
    @abc.abstractmethod
    def run(self, atom_ids: list[int], atoms: ase.Atoms, **kwargs) -> list[ase.Atoms]:
        pass

The run method expects as inputs

  • atom_ids: list[int], the ids of the currently selected atoms
  • atoms: ase.Atoms, the configuration as ase.Atoms file where atom_ids where selected.
  • kwargs: dict could be additional information from the scene

and as an output:

  • list[ase.Atoms], a list of ase Atoms objects to display.

You can define the parameters using pydantic.Field which will be displayed in the UI.

class MyUpdateCls(UpdateScene):
    steps: int = Field(100, le=1000, ge=1)
    x: float = Field(0.5, le=5, ge=0)
    symbol: str = Field("same")

To add your method click on the + on the right side of the window. Your should be able to add your method from the working directory via module.MyUpdateCls as long as it can be imported via from module import MyUpdateCls.

ZnDraw UI

ZnDraw UI2

ZnDraw UI3

Development

ZnDraw is developed using https://python-poetry.org/. Furthermore, the javascript packages have to be installed using https://www.npmjs.com/.

cd zndraw/static/
npm install

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zndraw-0.2.0a12.tar.gz (22.4 MB view details)

Uploaded Source

Built Distribution

zndraw-0.2.0a12-py3-none-any.whl (27.4 MB view details)

Uploaded Python 3

File details

Details for the file zndraw-0.2.0a12.tar.gz.

File metadata

  • Download URL: zndraw-0.2.0a12.tar.gz
  • Upload date:
  • Size: 22.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.10.8 Linux/6.2.0-26-generic

File hashes

Hashes for zndraw-0.2.0a12.tar.gz
Algorithm Hash digest
SHA256 6cf07e2cbcb0d4fa0aa801b2cda3ec15b91b40073d2895a1967e78e606d587c5
MD5 4e63d468b4285c9291ccec736f06b8db
BLAKE2b-256 2089037de21c49679df70783f8c554311fa6f5e7f0c54ce96584a8ac3f391223

See more details on using hashes here.

File details

Details for the file zndraw-0.2.0a12-py3-none-any.whl.

File metadata

  • Download URL: zndraw-0.2.0a12-py3-none-any.whl
  • Upload date:
  • Size: 27.4 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.10.8 Linux/6.2.0-26-generic

File hashes

Hashes for zndraw-0.2.0a12-py3-none-any.whl
Algorithm Hash digest
SHA256 8c38311b88f70a6f4a4f52e23c7ec27720509a61d17e18a15e96b60d465518ab
MD5 72f4feb063a35c8f5c18da19499253c0
BLAKE2b-256 5e5f64fcbd1bcc2e525c9c507b4b5d3a005c500bf75c821f41e407fe800ca0b4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page