Skip to content

Commit 4b6926b

Browse files
committed
add sub_steps back to the converted dataset
1 parent 133f643 commit 4b6926b

File tree

9 files changed

+27206
-2
lines changed

9 files changed

+27206
-2
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ keys.cfg
66
eval/logs/**
77
*.h5
88
logs/**
9-
9+
**/logs/**
10+
**/tmp/**
1011

1112
# -------
1213

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# code 1.6
2+
class Maxwell:
3+
""" The base class for evolution of Maxwell's equations.
4+
"""
5+
6+
def __init__(self, n_grid, x_out):
7+
"""Constructor sets up coordinates, memory for variables.
8+
The variables:
9+
mesh points:
10+
x: the x coordinate for each mesh grid
11+
y: the y coordinate for each mesh grid
12+
z: the z coordinate for each mesh grid
13+
t: the time coordinate of the simulation
14+
r: the distance to the origin for each mesh grid
15+
evolving fields:
16+
E_x: the x component of the field E
17+
E_y: the y componnet of the field E
18+
E_z: the z component of the field E
19+
A_x: the x component of the field A
20+
A_y: the y component of the field A
21+
A_z: the z component of the field A
22+
phi: the scalar potential field phi values
23+
monitor variables:
24+
constraint: the current constraint violation value from the evolving fields.
25+
26+
"""
27+
28+
self.n_grid = n_grid
29+
self.n_vars = 7
30+
self.delta = float(x_out) / (n_grid - 2.0)
31+
delta = self.delta
32+
33+
self.x = np.linspace(-self.delta*0.5, x_out + 0.5*self.delta, self.n_grid)[:,None,None]
34+
self.y = np.linspace(-self.delta*0.5, x_out + 0.5*self.delta, self.n_grid)[None,:,None]
35+
self.z = np.linspace(-self.delta*0.5, x_out + 0.5*self.delta, self.n_grid)[None,None,:]
36+
self.r = np.sqrt(self.x**2+self.y**2+self.z**2)
37+
38+
39+
# set up all variables common to both approaches
40+
self.E_x = zeros((n_grid, n_grid, n_grid))
41+
self.E_y = zeros((n_grid, n_grid, n_grid))
42+
self.E_z = zeros((n_grid, n_grid, n_grid))
43+
self.A_x = zeros((n_grid, n_grid, n_grid))
44+
self.A_y = zeros((n_grid, n_grid, n_grid))
45+
self.A_z = zeros((n_grid, n_grid, n_grid))
46+
self.phi = zeros((n_grid, n_grid, n_grid))
47+
self.constraint = zeros((n_grid, n_grid, n_grid))
48+
49+
50+
self.t = 0.0
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
class Block:
2+
def __init__(self, length, basis_size, operator_dict):
3+
self.length = length
4+
self.basis_size = basis_size
5+
self.operator_dict = operator_dict
6+
7+
def print_all(self):
8+
print(self.length)
9+
print(self.basis_size)
10+
for key, matrix in self.operator_dict.items():
11+
if isinstance(matrix, np.ndarray):
12+
print(f"{key}:\n{matrix}\n")
13+
else:
14+
print(f"{key}:\n{matrix.toarray()}\n")
15+
16+
class EnlargedBlock:
17+
def __init__(self, length, basis_size, operator_dict):
18+
self.length = length
19+
self.basis_size = basis_size
20+
self.operator_dict = operator_dict
21+
22+
def print_all(self):
23+
print(self.length)
24+
print(self.basis_size)
25+
for key, matrix in self.operator_dict.items():
26+
if isinstance(matrix, np.ndarray):
27+
print(f"{key}:\n{matrix}\n")
28+
else:
29+
print(f"{key}:\n{matrix.toarray()}\n")
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
def generate_dna(N: int, PWM: dict) -> tuple:
2+
'''
3+
Input:
4+
N (int): Length of the resultant DNA sequence.
5+
PWM matrix with keys 'A', 'C', 'G', 'T'
6+
7+
Output:
8+
tuple: Insertion location (int), DNA sequence (str), DNA reverse complement (str)
9+
'''
10+
p = random.randint(0, N-1)
11+
12+
nucleotide = "ACGT"
13+
uni_weights = [0.25,0.25,0.25,0.25] #uniform distribution
14+
dna_string = ''.join(random.choices(nucleotide, uni_weights, k=N))
15+
16+
spike_mat = load_motif_from_df(PWM)
17+
spiked_seq = ''.join(random.choices(nucleotide, weights=[PWM[nuc][i] for nuc in nucleotide], k=1)[0]
18+
for i in range(len(PWM['A'])))
19+
20+
complement = {'A':'T', 'T':'A', 'C':'G', 'G':'C'}
21+
reversed_seq = dna_string[::-1]
22+
reverse_complement = ''.join(complement[nuc] for nuc in reversed_seq if nuc in complement)
23+
24+
new_seq = dna_string[:p] + spiked_seq + dna_string[p:]
25+
new_seq_rc = reverse_complement[:N-p] + spiked_seq + reverse_complement[N-p:]
26+
27+
return p, new_seq, new_seq_rc
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
PROBLEM DESCRIPTION:
2+
You will be provided with the main description of the problem, previous steps, and the next step. Your task will be to generate the disciplinary knowledge necessary for solving the next step and then develop a Python solution focused on this step.
3+
4+
PREVIOUS STEPS DESCRIPTION:
5+
{problem_steps_str}
6+
7+
NEXT STEP - PROBLEM DESCRIPTION AND FUNCTION HEADER:
8+
This part will describe the next step in the problem-solving process. First, provide the necessary scientific background knowledge as a comment at the beginning of your response, starting with 'Background: '. Then, a function header will be provided, and your task is to develop the Python code for this next step based on the provided description and function header.
9+
10+
{next_step_str}
11+
12+
DEPENDENCIES:
13+
Use only the following dependencies in your solution. Do not include these dependencies at the beginning of your code.
14+
{dependencies}
15+
16+
RESPONSE GUIDELINES:
17+
1. Start with the scientific background required for the next step, formatted as a comment.
18+
2. Then write the complete and executable Python program for the next step in a single block.
19+
3. Your response should focus exclusively on implementing the solution for the next step, adhering closely to the specified function header and the context provided by the initial steps.
20+
4. DO NOT include previous function code, example usage or test code in your response.
21+
5. Ensure your response is in the format of ```python``` and includes the necessary background as a comment at the top.
22+
23+
Example:
24+
```python
25+
# Background: [Here, insert the necessary scientific knowledge required for the next step.]
26+
27+
[Insert the Python code here based on the provided function header and dependencies.]
28+
```
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
PROBLEM DESCRIPTION:
2+
You will be provided with problem steps along with background knowledge necessary for solving the problem. Your task will be to develop a Python solution focused on the next step of the problem-solving process.
3+
4+
PROBLEM STEPS AND FUNCTION CODE:
5+
Here, you'll find the Python code for the initial steps of the problem-solving process. This code is integral to building the solution.
6+
7+
{problem_steps_str}
8+
9+
NEXT STEP - PROBLEM STEP AND FUNCTION HEADER:
10+
This part will describe the next step in the problem-solving process. A function header will be provided, and your task is to develop the Python code for this next step based on the provided description and function header.
11+
12+
{next_step_str}
13+
14+
DEPENDENCIES:
15+
Use only the following dependencies in your solution. Do not include these dependencies at the beginning of your code.
16+
17+
{dependencies}
18+
19+
RESPONSE GUIDELINES:
20+
Now, based on the instructions and information provided above, write the complete and executable Python program for the next step in a single block.
21+
Your response should focus exclusively on implementing the solution for the next step, adhering closely to the specified function header and the context provided by the initial steps.
22+
Your response should NOT include the dependencies and functions of all previous steps. If your next step function calls functions from previous steps, please make sure it uses the headers provided without modification.
23+
DO NOT generate EXAMPLE USAGE OR TEST CODE in your response. Please make sure your response python code in format of ```python```.

0 commit comments

Comments
 (0)