-
Notifications
You must be signed in to change notification settings - Fork 1
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
base: main
Are you sure you want to change the base?
feat(model): particle in a box #44
Conversation
Define basic components
self.finite_box = FiniteBox.model_validate(finite_box) | ||
self.quantum_particle = QuantumParticle.model_validate(quantum_particle) | ||
|
||
def __call__(self) -> pd.DataFrame: |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the
from pydantic import BaseModel, Field, computed_field, field_validator | ||
|
||
|
||
PLANCK_CONST = 6.626e-34 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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? @emptymaleiWe also have
hbar
in https://docs.scipy.org/doc/scipy/reference/constants.html#physical-constants
+1
- To serialize the properties properly in Pydantic, we need
computed_field
. - 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: |
There was a problem hiding this comment.
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
particle_in_box.py