Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(model): particle in a box #44

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

GrumpySapiens
Copy link

  • Particle in a box
  • Module particle_in_box.py
  • Documentation
  • Tests
  • Tutorial
  • PR review

Define basic components
self.finite_box = FiniteBox.model_validate(finite_box)
self.quantum_particle = QuantumParticle.model_validate(quantum_particle)

def __call__(self) -> pd.DataFrame:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having a brain fart, wondering what should be the variables here. Should it be the box size or particle energy or both?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I were to write the code now, I would just input $x$ or $x, t$ and give a complex probability amplitude. Or an array of probability amplitudes if $x$ were an array.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the $x$ will be the displacement anywhere the user provides?

@GrumpySapiens GrumpySapiens self-assigned this Mar 26, 2024
@GrumpySapiens GrumpySapiens added documentation Improvements or additions to documentation enhancement New feature or request labels Mar 26, 2024
from pydantic import BaseModel, Field, computed_field, field_validator


PLANCK_CONST = 6.626e-34
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://docs.scipy.org/doc/scipy/reference/constants.html#physical-constants

Alternatively we may let the use decide the unit. Tiny numbers can become impractical.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, too small numbers could be impractical. Another option is not to use planck constant explicitly. Or do planck related calculations at the very end.



PLANCK_CONST = 6.626e-34
PI = 3.142
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:cvar p_height: potential well height
"""

length: float = Field(ge=0)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ge=0.0 for being a float.

Also the length you defined here is actually half-width. It may become tricky at some point..

class QuantumParticle(BaseModel):
r"""Definition of the quantum particle

:cvar energy: energy of the particle
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to set the ground energy, which is a quantity that the particle becomes unbounded at finite possibility. Something like this.

r"""Definition of the quantum particle

:cvar energy: energy of the particle
:cvar mass: weight of the particle
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mass of the particle

class WaveFunctionConst(BaseModel):
r"""Schrodinger equation simplification terms"""

@property
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Preferably cached_property or some kinds of computed field? @emptymalei

We also have hbar in https://docs.scipy.org/doc/scipy/reference/constants.html#physical-constants

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Preferably cached_property or some kinds of computed field? @emptymalei

We also have hbar in https://docs.scipy.org/doc/scipy/reference/constants.html#physical-constants

+1

  1. To serialize the properties properly in Pydantic, we need computed_field.
  2. Also better to cache it as this is used n-time-step times.

self.finite_box = FiniteBox.model_validate(finite_box)
self.quantum_particle = QuantumParticle.model_validate(quantum_particle)

def __call__(self) -> pd.DataFrame:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I were to write the code now, I would just input $x$ or $x, t$ and give a complex probability amplitude. Or an array of probability amplitudes if $x$ were an array.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants