Skip to content

Commit

Permalink
Inputs files in V or mV
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinAchondo committed Jul 9, 2024
1 parent 6690ec9 commit 2f50151
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
9 changes: 5 additions & 4 deletions xppbe/Mesh/Mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,10 @@ def create_mesh_obj(self):
X_plot[f'{type_b}_sample'] = mesh.get_dataset().numpy()
self.save_data_plot(X_plot)

def adapt_meshes_domain(self,data,q_list):
def adapt_meshes_domain(self,data,q_list,to_V):

self.meshes_info = data
self.to_V = to_V.numpy()

for bl in self.meshes_info.values():

Expand Down Expand Up @@ -340,7 +341,7 @@ def adapt_meshes_domain(self,data,q_list):
elif ens_method in current_method:
if line:
num, phi = line.split()
L_phi[str(num)] = float(phi)
L_phi[str(num)] = float(phi)/(1000*self.to_V)

L_names = ['H']
if 'sphere' in self.molecule or self.molecule == 'born_ion':
Expand Down Expand Up @@ -379,7 +380,7 @@ def adapt_meshes_domain(self,data,q_list):
for q in q_list:
if q.atom_name in L_names:
if str(j) in L_phi:
phi_ens = tf.constant(L_phi[str(j)] , dtype=self.DTYPE)/1000
phi_ens = tf.constant(L_phi[str(j)] , dtype=self.DTYPE)
xq = tf.reshape(tf.constant(q.x_q, dtype=self.DTYPE), (1,3))
r_q = tf.constant(q.r_q, dtype=self.DTYPE)
X_exp_values.append(((xq,r_q),phi_ens))
Expand Down Expand Up @@ -440,7 +441,7 @@ def read_file_data(self,file,domain):
x_b = tf.constant(np.array(x_b, dtype=self.DTYPE)[:, None])
y_b = tf.constant(np.array(y_b, dtype=self.DTYPE)[:, None])
z_b = tf.constant(np.array(z_b, dtype=self.DTYPE)[:, None])
phi_b = tf.constant(np.array(phi_b, dtype=self.DTYPE)[:, None])
phi_b = tf.constant(np.array(phi_b, dtype=self.DTYPE)[:, None])/self.to_V

X = tf.concat([x_b, y_b, z_b], axis=1)

Expand Down
2 changes: 1 addition & 1 deletion xppbe/Model/PDE_Model.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def get_loss_experimental(self,model,X_exp):
phi_ens_pred_L = self.get_phi_ens(model,(X,flag),q_L,method)

for phi_pred,phi_exp in zip(phi_ens_pred_L,phi_ens_exp_L):
loss += tf.square(phi_pred - phi_exp/self.to_V)
loss += tf.square(phi_pred - phi_exp)

loss *= (1/n)

Expand Down
2 changes: 1 addition & 1 deletion xppbe/Simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def create_simulation(self):
if t in meshes_domain:
self.meshes_domain[t] = meshes_domain[t]

self.PBE_model.mesh.adapt_meshes_domain(self.meshes_domain,self.PBE_model.q_list)
self.PBE_model.mesh.adapt_meshes_domain(self.meshes_domain,self.PBE_model.q_list,self.PBE_model.to_V)

from xppbe.NN.PINN import PINN
self.PINN_solver = PINN(results_path=self.results_path)
Expand Down

0 comments on commit 2f50151

Please sign in to comment.