Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/cmgcds/fastvpinns into main
Browse files Browse the repository at this point in the history
  • Loading branch information
thivinanandh committed Apr 24, 2024
2 parents 8ec72d8 + 122ce1c commit 3c7b647
Show file tree
Hide file tree
Showing 21 changed files with 5,173 additions and 0 deletions.
80 changes: 80 additions & 0 deletions examples/forward_problems_2d/complex_mesh/cd2d/cd2d_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Example file for the poisson problem
# Path: examples/poisson.py
# file contains the exact solution, rhs and boundary conditions for the poisson problem
import numpy as np
import tensorflow as tf


def left_boundary(x, y):
"""
This function will return the boundary value for given component of a boundary
"""
return 0.0


def right_boundary(x, y):
"""
This function will return the boundary value for given component of a boundary
"""
val = 0.0
return val


def top_boundary(x, y):
"""
This function will return the boundary value for given component of a boundary
"""
val = 0.0
return np.ones_like(x) * val


def bottom_boundary(x, y):
"""
This function will return the boundary value for given component of a boundary
"""
return 0.0


def rhs(x, y):
"""
This function will return the value of the rhs at a given point
"""
f_temp = 32 * (x * (1 - x) + y * (1 - y))

return f_temp


def exact_solution(x, y):
"""
This function will return the exact solution at a given point
"""

val = 16 * x * (1 - x) * y * (1 - y)

return val


def get_boundary_function_dict():
"""
This function will return a dictionary of boundary functions
"""
return {1000: bottom_boundary, 1001: right_boundary, 1002: top_boundary, 1003: left_boundary}


def get_bound_cond_dict():
"""
This function will return a dictionary of boundary conditions
"""
return {1000: "dirichlet", 1001: "dirichlet", 1002: "dirichlet", 1003: "dirichlet"}


def get_bilinear_params_dict():
"""
This function will return a dictionary of bilinear parameters
"""
eps = 1.0
b_x = 1.0
b_y = 0.0
c = 0.0

return {"eps": eps, "b_x": b_x, "b_y": b_y, "c": c}
75 changes: 75 additions & 0 deletions examples/forward_problems_2d/complex_mesh/cd2d/input.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# This YAML file contains configuration parameters for a variational physics-informed neural network (VarPINN) experimentation.

experimentation:
output_path: "output/cd2d/1" # Path to the output directory where the results will be saved.

geometry:
mesh_generation_method: "external" # Method for generating the mesh. Can be "internal" or "external".
generate_mesh_plot: True # Flag indicating whether to generate a plot of the mesh.

# internal mesh generated quadrilateral mesh, depending on the parameters specified below.

internal_mesh_params: # Parameters for internal mesh generation method.
x_min: 0 # Minimum x-coordinate of the domain.
x_max: 1 # Maximum x-coordinate of the domain.
y_min: 0 # Minimum y-coordinate of the domain.
y_max: 1 # Maximum y-coordinate of the domain.
n_cells_x: 4 # Number of cells in the x-direction.
n_cells_y: 4 # Number of cells in the y-direction.
n_boundary_points: 400 # Number of boundary points.
n_test_points_x: 100 # Number of test points in the x-direction.
n_test_points_y: 100 # Number of test points in the y-direction.

exact_solution:
exact_solution_generation: "external" # whether the exact solution needs to be read from external file.
exact_solution_file_name: "" # External solution file name.

mesh_type: "quadrilateral" # Type of mesh. Can be "quadrilateral" or other supported types.

external_mesh_params: # Parameters for external mesh generation method.
mesh_file_name: "../meshes/circle_quad.mesh" # Path to the external mesh file (should be a .mesh file).
boundary_refinement_level: 4 # Level of refinement for the boundary.
boundary_sampling_method: "lhs" # Method for sampling the boundary. Can be "uniform" or "lhs".

fe:
fe_order: 6 # Order of the finite element basis functions.
fe_type: "legendre" # Type of finite element basis functions. Can be "jacobi" or other supported types.
quad_order: 10 # Order of the quadrature rule.
quad_type: "gauss-jacobi" # Type of quadrature rule. Can be "gauss-jacobi" or other supported types.

pde:
beta: 10 # Parameter for the PDE.

model:
model_architecture: [2, 50,50,50,50, 1] # Architecture of the neural network model.
activation: "tanh" # Activation function used in the neural network.
use_attention: False # Flag indicating whether to use attention mechanism in the model.
epochs: 50000 # Number of training epochs.
dtype: "float32" # Data type used for computations.
set_memory_growth: False # Flag indicating whether to set memory growth for GPU.

learning_rate: # Parameters for learning rate scheduling.
initial_learning_rate: 0.001 # Initial learning rate.
use_lr_scheduler: False # Flag indicating whether to use learning rate scheduler.
decay_steps: 1000 # Number of steps between each learning rate decay.
decay_rate: 0.99 # Decay rate for the learning rate.
staircase: False # Flag indicating whether to use staircase decay.


logging:
update_progress_bar: 100 # Number of steps between each update of the progress bar.
update_console_output: 5000 # Number of steps between each update of the console output.
update_solution_images: 10000 # Number of steps between each update of the intermediate solution images.
plot_residual_images: True
test_error_last_n_epochs: 1000

wandb:
use_wandb: False # Flag indicating whether to use Weights & Biases for logging.
project_name: "Volker_example_2" # Name of the Weights & Biases project.
wandb_run_prefix: "without_scaling" # Prefix for the Weights & Biases run.
entity: "starslab-iisc" # Weights & Biases entity.

additional:
run_by: "Thivin" # Name of the person running the experiment.
System: "24" # System identifier.

Loading

0 comments on commit 3c7b647

Please sign in to comment.